Problems with Lives

0 favourites
  • 4 posts
From the Asset Store
Full game Construct 2 and Construct 3 to post on Google Play
  • Guys, I'm having a lot of headache trying to get rid of an annoying bug that is happening with the lives system of my game.

    So I'm here humbly asking for your help! q.q

    The player sprite have a boolean that sets when it dies. This boolean is activated everytime player sprite touches an enemy sprite.

    The boolean activated triggers a death event, that substracts 1 from a global variable "Lives"

    and there is an game over event, triggered when the global variable "Lives" equals zero.

    the "vulnerable" boolean is used to make the player invulnerable when it is carrying eggs

    <img src="http://i10.photobucket.com/albums/a126/shinobi_br/lives_problem_zps013ff013.png" border="0" />

    Now here's the problem, sometimes, when 2 enemies touch the player at the same time, or when a enemy touches the player twice (for example, touches it when jumping and once again when falling), 2 lives are substracted instead of one. Also, sometimes, if this happens when you have 1 life left, it starts counting negative, instead of 0, for consequence the player gets stuck at the stage.

    I tried to disable the collision at the moment player touches an enemy, but still, the problem persists.

    Any ideas about how to solve this? I'm getting crazy with it! (????)?? ???

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Um...I guess one thing you could try is putting an "else" event on top of all the blocks following the first collision.

    Basically that will force the program to read like this "did he collide with this guy? no, then how about this guy" instead of "he collided with this and this and this"

    At least that's how I understand it.

  • Used "Trigger only once" at the Death event. It seems like it's solved.

  • You should also change lives = 0 to lives <= 0. It's more robust that way - in case the lives variable ever goes negative for any reason, you'll be covered.

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