Working through my first "game" and things were going smoothly until today when I tried to introduce a second Layout AND timelines into the mix. My experience with programming (and Construct) is limited so I'm wondering if there's something obvious I'm missing here.
- > When player gets certain # of points, they can access a new "door"
- > When they enter the "door" (on collision), they are brought to a new layout (Layout 2).
- > On start of this layout, the player views a short animation (timeline begins on start of layout, player cannot access any controls), screen fades to black, and they are brought back to the title screen
Steps 1 and 2 are working as far as I can tell. But:
1) There have been a few instances where I'm seeing different behavior when starting Layout 2 from preview vs. entering from Layout 1.
For example, if I use the event sheet below (gameover.png), the whole sequence plays properly when I start the layout with preview. If I play the game and enter from Layout 1, the "Go to StartScreen" fires off about 3 seconds into the timeline. This seems odd because Layout 2 has its own event sheet and there is no inherited code between the two (since it's all animation).
2) Events based on timeline triggers are behaving differently depending on the trigger, but I don't know why.
I thought maybe I wasn't being specific enough with my timeline event, so I set it to fire off the transition + gameover functions after the timeline is "finished." If I try the below (gameoveralt.png), I can get all the way to the end of the animation in Layout 2 preview mode AND when entering from Layout 1, BUT now the fade in doesn't work properly.
I've tried a few other things and they're all ALMOST there but something goes awry. Even if I manage to blunder my way into a solution, I'd love to know if there's a bigger picture thing I'm missing here about layout transitions, timelines, or life in general. And, happy to share CAPX if it's helpful.
Thanks in advance.
Can you share your project? That is the best for us to be able to figure out what is going on.
Of course. Apologies if it's a bit messy in there. WAD to move...the big pink box on Layout 1 is what transitions you to Layout 2.
Looking at this now, sorry about the delay, I was hanged up with a few other things!
No worries. I found an interim solution using "Wait" so I wasn't blocked : ). Would be great to hear your thoughts on the capx though!
There seems to be a difference in how events are handled when you preview them directly and when you transition between them, need to investigate that further.
That difference is causing your first attempt with a not playing condition to fail, because while it works when you preview the layout directly, as you would expect, because the Play action comes before the check... when you enter from another layout the condition is hit once, before the timeline starts playing, starting the whole process to exit the layout before the timeline is finished.
Your second attempt, avoids that problem by using the On Finished condition, but the fade to black transition does not work, because the trigger is only hit once, so updating the opacity based on a delta, doesn't work.
In order for that to work, you would need to set a flag on the On Finished trigger, and then based on that flag decide when to start playing your fade to black animation, elsewhere in the event sheet.
You could also add the instance that is the black background to Layout 2, set it to opacity 0% in the editor, and animate it in the same timeline you are using to move the cat. Below an example file showing that method. The good thing is you can get rid of some of the events, as the timeline takes care of everything regarding the animation.
Your game reminds me of an old DOS game, Alley Cat https://www.youtube.com/watch?v=uZDG4dlU5uY
Develop games in your browser. Powerful, performant & highly capable.
Thanks so much for this explanation! Agreed using the timeline is the simplest way to do this...I think I was using the layout transitions in sample projects as a reference so I didn't think of it.
I think I'm following but will play around a bit to see if I can get it to work with events based on your suggestions. Regarding the .zip -- is there supposed to be a CAPX in there or should I be trying to open in browser?
That Alley Cat game is so awesome! Thank you for sharing. I love the little detail of the cat crashing to the ground and reappearing after you get kicked out of the windows. Lots of good stuff to pull from...especially if/when I decide to take Frankie out of the apartment and into the streets.
You can just open the .zip file as if it was a .c3p file in C3, infact .c3p files are just .zip files with a different extension :P.
Some websites complain when you try to upload files with strange file formats, so changing to .zip works. I do it without even thinking now, so I forget a lot of our users don't even know you can do that.