Get help using Construct 2

Post » Thu Feb 14, 2013 7:43 pm

I'm trying to make a platform game with levels, I'm having some trouble adding lives into the game.

I'm having it something like = Player outside of layout = death (-1 life)

I used a picture with 3 hearts that I anchored to the top left of the screen, but I can't seem to get it to destroy one heart at a time if the player dies? I'm trying to make it so that the lives reset when you finish the level (and move to next layout). And one last thing, when the player runs out of lives, how do I make it so that he goes to a "Game Over" layout?

Please help and thank you.grimsky2013-02-14 19:44:04
Posts: 2
Reputation: 379

Post » Thu Feb 14, 2013 8:16 pm

There's a few different ways to accomplish this.

Setting up the heart containers.

One next trick is to create your heart sprite in a tiled background object instead of as a normal sprite. Then you set the width to X times the width of the heart times the number of lives the player has.

eg: if the heart is 64 pixels wide. Each time you increase the width of the tiled background heart container by 64 pixels, another heart will appear or disappear. (make sure you set the origin point of the object to the left or top left of the sprite so that it will scale properly.

Subtracting the lives

Create a global variable called "Lives" and give it an initial value of 3 lets say.

Event 1
On start of layout -> Set width of HeartContainer to Lives * 64 (or whatever width your heart is)

(Player) Is outside of layout
(system)Trigger once while true

-> subtract from "Lives" 1
-> Set width of HeartContainer to Lives * 64 (or whatever width your heart is)

Event 3
(system) Lives = 0 -> goto layout "Game Over"

Voila!justifun2013-02-14 20:23:30
Posts: 1,012
Reputation: 18,607

Post » Wed Feb 20, 2013 7:07 pm

Thank you, it worked
Posts: 2
Reputation: 379

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 3 guests