How do I view and manage the lifes/hearts of a player

0 favourites
  • 5 posts
From the Asset Store
Basic Rounded Vector Geometry Player Design with Glow for 3 player games
  • Right now I simply have 5 sprites anchored on the players layer. But how can I remove one heart when the player dies? How do I know which one to remove? I know I could select by UID, but what if I want to have different amounts of starting lifes?

    Any help would be greatly appreciated

  • There's different ways to go about it, the one i usually use a single sprite with different frames for the amount of hearts. First frame (which is frame 0) has no heart, frame 1 has 1 heart, etc. I set the animation speed to 0 then i set the frame to match my player's life variable.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • This sadly limits the maximum amounts of hearts I can have to the size of my sprite :/

    If at all possible I would like the lifes of the character to only be limited by the width of the screen (or a limitation I can set however I want).

    But for the time being, a sprite with multiple frames seems a good idea

  • Why don't you just use a tiled background and set it's width according to the number of lives that you have

    https://www.scirra.com/manual/118/tiled-background

  • Not sure what you mean by this

    This sadly limits the maximum amounts of hearts I can have to the size of my sprite :/

    This tutorial shows the method described by kraed

    https://www.scirra.com/tutorials/565/be ... -indicator

    Another idea is to stay with your original method, but to answer the question

    But how can I remove one heart when the player dies? How do I know which one to remove?

    you can do:

    Event

    System: Pick sprite instance sprite.Count - 1

    Action

    sprite: Destroy

    Assuming they are displayed in the order they were created in (might need to re-order them first).

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