Lives?

0 favourites
  • 3 posts
  • 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.

  • 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)

    Event2

    (Player) Is outside of layout

    AND

    (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!

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Thank you, it worked

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)