What expression?

Get help using Construct 2

Post » Fri Sep 04, 2015 5:57 pm

What expression would I put into a sprite if I wanted it to lose some width everytime the player got hit
B
25
S
6
G
4
Posts: 173
Reputation: 3,933

Post » Fri Sep 04, 2015 6:21 pm

you could use
set width | self.Width - 'value'

value is the amount you wish to deduct from the width of sprite
B
28
S
6
G
2
Posts: 86
Reputation: 3,267

Post » Fri Sep 04, 2015 6:29 pm

for some reason, when I put minus it counts as a syntax error
B
25
S
6
G
4
Posts: 173
Reputation: 3,933

Post » Fri Sep 04, 2015 6:31 pm

@Ayolabi12345
are you able to post a link to your file for us to look at
B
28
S
6
G
2
Posts: 86
Reputation: 3,267

Post » Fri Sep 04, 2015 6:34 pm

nvm thank you very much
now I can move forward. For sure you will be in my credits
B
25
S
6
G
4
Posts: 173
Reputation: 3,933

Post » Fri Sep 04, 2015 6:34 pm

@Gweely I figured it out
B
25
S
6
G
4
Posts: 173
Reputation: 3,933

Post » Fri Sep 04, 2015 6:37 pm

@Gweely although, how do I make it change from green to yellow at a certain point then yellow to red at another?
B
25
S
6
G
4
Posts: 173
Reputation: 3,933

Post » Fri Sep 04, 2015 7:57 pm

@Ayolabi12345

Try looking at this.
Might not be the best ways to do it , but might help a little.


PowerBars.capx
B
28
S
6
G
2
Posts: 86
Reputation: 3,267

Post » Fri Sep 04, 2015 8:17 pm

If you want to make a health bar (or power bar) you can try:
HealthBar.width=(Self.InitialWidth + (Player.Health-PlayerMaxHealth)*(Self.InitialWidth/PlayerMaxHealth))
InitialWidth = instance variable
Change color:
You could use setcolor effect:
with function you can set color
*compare player.health > 66/100*playerMaxHealth then set color "green"
playerHealth is between 66/100*playerMaxHealth and playerMaxHealth*33/100 then set color "yellow"
playerHealth <33/100*playerMaxHealth then set color "red"
Image Image
B
25
S
14
G
137
Posts: 876
Reputation: 71,505

Post » Sat Sep 05, 2015 8:26 am

If you want to have your life bar gradually change color, do this :

Add a "SetColor" effect on your bar and set these defaults values :
Red 0
Green 100
Blue 0

Then do this :
Image
B
12
S
7
G
7
Posts: 450
Reputation: 4,276


Return to How do I....?

Who is online

Users browsing this forum: Artcadev, Blendi1223, dop2000, Google [Bot], oosyrag and 50 guests