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

Get help using Construct 2

Post » Fri Jul 25, 2014 12:45 am

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:
Image

Thanks,
guannstar
B
28
S
5
G
1
Posts: 594
Reputation: 3,286

Post » Fri Jul 25, 2014 4:35 pm

Bump.
B
28
S
5
G
1
Posts: 594
Reputation: 3,286

Post » Fri Jul 25, 2014 6:07 pm

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"))
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Sat Jul 26, 2014 4:11 pm

Thanks LittleStain, I'll try that and see if it works.
B
28
S
5
G
1
Posts: 594
Reputation: 3,286

Post » Sun Jul 27, 2014 3:25 am

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?

Image
B
28
S
5
G
1
Posts: 594
Reputation: 3,286

Post » Sun Jul 27, 2014 6:48 am

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..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Sun Jul 27, 2014 2:25 pm

Okay thanks, I'll try that and get back to you.
B
28
S
5
G
1
Posts: 594
Reputation: 3,286

Post » Sun Jul 27, 2014 3:10 pm

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!
B
28
S
5
G
1
Posts: 594
Reputation: 3,286

Previous

Return to How do I....?

Who is online

Users browsing this forum: David181 and 15 guests