How do I activate a Weapon Power Up?

Get help using Construct 2

Post » Sat Jan 16, 2016 2:14 pm

I'm brand new to Construct 2, and I'm trying to make a complex platformer. Smart idea, I know. </sarcasm> :|

The issue I'm having right now is related to Power ups. I'm trying to make it so that when my character touches a spinning wrench icon, it switches to him holding the wrench (a different animation), and when he runs, it's playing another animation. However, I want it so that the animation plays for about 10 seconds, then reverts back to the first sprite animations (Idle and Run).

Please take note that I followed the beginner's tutorial, so his sprite is connected to an invisible PlayerBox object. I've tried duplicating the character sprite so that it replaces the original, but then it gives me problems with the placement (where the duplicate does not exactly follow the PlayerBox, despite me having put 'position to PlayerBox').

Here is what I currently have in my event sheet:

Posts: 11
Reputation: 647

Post » Sat Jan 16, 2016 3:18 pm

There are, as always, multiple ways of doing this. My first idea is to have an instance variable on the player called something like "PowerUp" and the timer behaviour. When the player collides with the wrench set the PowerUp to "_Wrench"(you can do it without the underscore). Start the timer and make it last 10 seconds and put a tag to something like "power_up". Now, for your animations, whenever you player any animation make it so it plays "Idle" & Tails.PowerUp, "Jump" & Tails.PowerUp, and so on. Since the PowerUp variable will be an empty string in the beginning it will play just "Idle", "Jump", etc. When you collect the wrench it will begin playing "IdleWrench", "JumpWrench", etc. You have to remember to make these animations.
The last thing is to add an event On timer and make it so when the timer expires(the "power_up" one), just set the Tails.PowerUp to ""(this is an empty string).

This can also work even better with families, if you want me to further explain how incorporating families will make the code more streamlined and make it so adding new power ups is easy feel free to ask(I don't have time to do so now :( ).

I assumed that Tails is the player in the later part.
Banned User
Posts: 105
Reputation: 1,170

Return to How do I....?

Who is online

Users browsing this forum: asdtricky, brunopalermo, ST314 and 41 guests