Three lifes problem

0 favourites
  • 6 posts
From the Asset Store
Three Reel Slots
$4.75 USD
5% off
A slots game template designed to be skin-able for mobile
  • Hello,

    at first I apologise for very stupid begginer question. I am trying to create lifes of player and show them in the hud (I am basically show smaller version of player's airplane as one life. Basically player sprite has variable "life" starting value is 3. So at beginning there is three of them.

    then in events I have something like this:

    <img src="http://img232.imageshack.us/img232/7643/liff.jpg" border="0" />

    and then in another condition I have something like if player collides with enemy substract 1 from "life variable.

    It works but I think this sollution is kinda sketchy and not right in sense of programming sense?

    I suppose I should use for or foreach loop somehow? Thank you

  • I think at every tick now, its going to be creating more and more objects because it still meets that condition.

    The best way would to be using 3 already pre-made objects on the screen and adjusting their visibility based on it meeting the life requirement.

    You also don't need it on every tick, you could just have them only check when an event which affects life is done. So as a sub-event of your GOT ATTACKED event, you reduce life by 1, and if life is = 2, set visibility of invisible to one etc.

  • hmm, I think this will slow down your game a lot to create the sprites every tick.

    Is your game fixed to a max of 3 lifes? If it is, I would suggest to just put 3 instances of the sprite to your game directly and give them individual names. Based on the life variable, you should then just toggle the visibility to true/false. This will speed up everything a lot.

    EDIT: Damn Ninjas :)

    EDIT 2:

    Another solution, that would be faster:

    Set up the Life Sprite as a tiles background object. Based on your life, you can then just set the width of the object to show the correct number of hearts. With this, you would only need one action that calculates the necessary width of the background by (width of heart * # of lifes).

  • Ubivis bright minds think alike, fellow ninja. Haha!

  • Just made an example of my second suggestion, works very nice :)

    Download

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thanks guys. I am starting to love this friendly community :). I hope one day I will be helpful to others as you

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