How do I create a life metre using sprites

0 favourites
  • 3 posts
From the Asset Store
With this template you will learn how to use the GooglePlay Games native plugin
  • I'm currently creating a platforming game, where when the player takes a hit or falls outside the layout, 1 is subtracted from the instance variable lives, of the player, and then I call a function so that if lives = 3, set it to the full heart, 2, set it to one quarter taken away, as such:

    I had the code to subtract from and add to the instance variable when there's a collision with the related object (I tried having the subtract/add 1 to the lives variable within the functions themselves, but that didn't work either for me)

    Similar I have a gainLives method, that on collision with a heart pick up, add 1 to the players lives, and do the same with the animation.

    But the problem is, it's quite random when it decided to follow these. The player will walk into a enemy, and flash like they took damage, but the health won't change, they'll walk into the enemy again, and it'll go down by one. The same happens when picking up health. I was wondering if it would be better to use global variables instead, or if there's a different solution I don't know off (I've only found Construct recently as it's the program I need to use for an assignment).

    Any help is greatly appreciated

  • ,,,,,,,,,,,,,,,,,,,,,

  • 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's fixed my issue with the death event but the health items for some reason won't increase it, even though I changed it to on collision add 1 to lives instead of calling a function...

    EDIT: Nevermind! I realized I had a function for a "health" family, to enable particle effects and sound on picking up any health piece, and putting add 1 to lives there fixed my issue. Thanks (:

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