How do I subtract a portion of width from a tiled object!?

  • Hello all! Okay, so I tried something different with my code and I made it so that LifeHearts (my "lives left" tiled object) is controlled by a global var instead of an instance var. This time, the adding and subtracting of the width works fine, when you beat a level it perfectly adds 24 pixels (adds a heart) and it shows up on the next level/layout as it should. The problem is that when I lose the level and restart it, my LifeHearts (the hearts/lives left) object will not show up again on level. It seems like my LifeHearts object is being told to disappear somehow even though I made it so that, every tick, LifeHearts will remain visible. Why is this happening... I mean, why does my LifeHeart tiled object just disappear, but only when I lose/have to restart a level?

    Here's my code:

    Thanks,

    guannstar

  • Bump.

  • first off all..

    Why set something visible every tick?

    When retrieving a number value from webstorage you should use int, because otherwise it will return a string instead of a number..

    I guess that's where the issue is..

    set varlifehearts to int(webstorage.localvalue("LiveHearts"))

  • Thanks LittleStain, I'll try that and see if it works.

  • Hey LittleStain, I tried what you said and it worked at first (when there was no 'subtract from' code at all). So, without the 'subtract from' code there, when I would die, the LifeHearts (lives left) will now show up again and are visible on the screen/layer, as they should be (so basically, adding the int partially fixed it). There's still a slight visibility problem though, but, it only occurs (disappears) when I add in the 'subtract from' code for some reason (the code is highlighted below). So, my question is, why are the LifeHearts (lives left) disappearing now, but only when I 'subtract from' varLifeHearts and not when I 'add to' varLifeHearts?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • the condition is true every tick the characters health is less than 0, so the total width should be 0 in no time..

    Add a system trigger once and all will be ok..

  • Okay thanks, I'll try that and get back to you.

  • Yeah, it did work... omg, it all works now, thanks a lot man. LittleStain, you're the best! Blessings upon you a thousand times lol!

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