How do I create a global var "number of lives left system"?

  • Hello everybody, I have a question. If I have thirteen objects (like the hearts below) in a family/group, how would I make it so that every time the character's health hits 0, you would lose a heart or life. Then I'd make it so that when there are no hearts/lives left, you would have to start from the first level. Am I going about it the wrong way by put all thirteen hearts/objects into a family/group? How do I do this?

    Thanks,

    guannstar (Fnord)

  • I would actually use a tiled background, then set the width to livesLeft * imageWidth, that way you dont have to deal with picking objects and annoying stuff like that

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Sorry, is there a guide or something that can roughly show me how to do that? Do you know of any good tutorials? I think what you're saying, is exactly what I'm looking for:)

  • Check the capx.

    In your project change int(TextBox.Text) to your current number of lives left.

  • Thanks, this is very cool:) I try it and get back to you.

  • Hi, I can't get the tiled background object to work either:( Two problems, the first is that I don't know how to take a specific width away from the tiled object. For example, see the highlighted section below... I can only "Set width" to 24 pixels, rather than subtract 24 pixels from the tiled object. The second problem is that every time I restart the layout, the size of the tiled object (the heart) reverts back to its original size, which defeats the whole purpose. Can somebody please please show me how to make a "lives left per level/layout" system using a global variable (so that the tiled object size wont refresh every time the layout does)?

  • Bump, please I really need some help.

  • To subtract you have to enter an expression like this.

    Set Width to

    lifehearttiled.width-24

    this get the current width and subtracts 24 from it.

    To get this simply highlight the box where you enter the information. Click the object you are referencing in the

    "Objects With Expressions"

    pane and scroll down until you find width then double click it.

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