Set Time Relative to an Action...

Get help using Construct 2

Post » Wed Feb 27, 2013 9:54 pm

Hello all,

I'm working on my first game with Construct 2, a very simple pinball game, and am having trouble figuring out how to create a time setting that follows an action.

I have three small bars that when in contact with the ball turn to a different animation. They are all right next to each other and if you get all three at the same time, your score will go nuts.

The issue is I can't figure out how to make them keep an animation active for 15 seconds AFTER they have been hit with the ball. All I have come up with is how to make them default back after 15 seconds of game play. I want each to hold their animation for 15 seconds after being hit.

I've been pulling my hair out for an hour now and all over the forum. Any help would be greatly appreciated!
Thanks!

http://billionyearbunker.com/development/pinball/v4/
B
17
S
8
G
1
Posts: 25
Reputation: 2,649

Post » Thu Feb 28, 2013 12:29 am

Give the bar an instance variable 'timer' = 0.

+on collision
   -> set bar animation to "active"
   -> set bar.timer to 15.

+bar.timer > 0
   ->set bar.timer to max(0, bar.timer - dt)
   +bar.timer = 0
      -> set bar animation to "normal"


https://www.scirra.com/tutorials/450/timers
B
54
S
28
G
18
Posts: 1,520
Reputation: 25,020

Post » Fri Mar 01, 2013 2:44 am

Oh man, it was right in front of me.

Thanks so much!
B
17
S
8
G
1
Posts: 25
Reputation: 2,649


Return to How do I....?

Who is online

Users browsing this forum: GSquadron, Yahoo [Bot] and 26 guests