Problem with Lives in a game!

Hi. I am making this game so that when lives run out, it changes scenes. When I put in the following code, It just made the screen freeze. Can anybody please help me?


When all of the following are happening:

if game.Lives = 0

Change Scene go to Game Over

Comments

  • CodeMonsterCodeMonster ACT, AustraliaMember Posts: 1,078
    Well I always keep stuff like pause. Game over and game complete all in one scene. So I'm not sure about this

    But I would suggest making a custom pause behaviour and when lives = 0
    Then make the custom pause active and display an image saying game over. If you don't know how to do this there is plenty of videos on youtube about it.
  • Thunder_ChildThunder_Child Member Posts: 2,343



    When all of the following are happening:

    if game.Lives = 0

    Change Scene go to Game Over
    This seems like a pretty simple task....may seem like a stupid answer but make your trigger "If ANY OF THE FOLLOWING...and make it if game.Lives is equal or LESS THAN symbol....just try a different trigger...I'm assuming your Game over scene has very little in it....go turn off all code in that scene, turn them on one at a time and see when it starts crashing....it's tedious but for a noob like myself...that's what I would and have done to troubleshoot when needed...


  • KevinCrossKevinCross London, UKMember Posts: 1,894
    Just a guess, what's the default value for game.Lives when your game first boots? Is it set as 0 in the list of attributes? Could it be that this is triggering as soon as the game is booted?

    Aside from that it looks fine so maybe you've got something on the Game Over scene it doesn't like. Try creating a new blank scene and send your code to that instead of the current Game Over scene to see if that works.
  • rajit.garg11rajit.garg11 Member Posts: 11
    No. As soon as all the lives run down in the game, the scene turns black and freezes. Sorry for not clarifying this. :P
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    Try creating a new blank scene and send your code to that instead of the current Game Over scene to see if that works.
    But did you do this? We can't help you further without knowing the result of this step...

    After you do that, if you're still having trouble you can resort to Log Debugging Statements. Just add them at key points in your game (e.g. right before a game over condition and right after) and then watch the debugger window to see which statements appear right before the crash. That will give you a clue about what might be causing it.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

Sign In or Register to comment.