How do I correct my variables??

Get help using Construct 2

Post » Mon Jan 30, 2017 2:28 pm

hi

i have a variable "var1" at the beginign of the layer the value is 300 i would like to do this:

every time i click, it remove -5 from "var1" so it goes from 300 to 295, 290 etc etc this actually works fine.

IM STUCK AT THIS:

i have a sprite "lifebar" with ha maximum size of 300

i would like every time my "var1" lose -5 the "lifebar" width lose -5

how to achive that formula?? :P
B
41
S
16
G
7
Posts: 1,779
Reputation: 10,029

Post » Mon Jan 30, 2017 2:42 pm

Every tick | set Lifebar.Width to 300*(var1 / 300 )

Also, don't forget to set Lifebar Origin to the left(or right, whichever you prefer.)
Image Image Image
B
33
S
12
G
27
Posts: 761
Reputation: 17,286

Post » Mon Jan 30, 2017 2:50 pm

i cant get it, something is wrong :s

at the start of my level the var 1 is a 300 when the var1 reach 0, it restart but with 400, after when reach again 0, it restart with 500 etc etc
but the problem is my life bar grows too :s i would like to keep 300 maximum and only remove -5 in width from the value of var1
B
41
S
16
G
7
Posts: 1,779
Reputation: 10,029

Post » Mon Jan 30, 2017 3:06 pm

imothep85 wrote:i cant get it, something is wrong :s

at the start of my level the var 1 is a 300 when the var1 reach 0, it restart but with 400, after when reach again 0, it restart with 500 etc etc
but the problem is my life bar grows too :s i would like to keep 300 maximum and only remove -5 in width from the value of var1


Try my capx. https://www.dropbox.com/s/96t59h6iltc1f ... .capx?dl=0
Note that this is also a timer bar but both adding and subtracting life works. Just modify the capx to fit your needs.
Image Image Image
B
33
S
12
G
27
Posts: 761
Reputation: 17,286

Post » Mon Jan 30, 2017 3:15 pm

Thanks :D
B
41
S
16
G
7
Posts: 1,779
Reputation: 10,029

Post » Mon Jan 30, 2017 4:16 pm

oen thing i dont understand is this

i have a formula like this

global number "difficulty_var" = 300
everytime i click
substract 5 from "difficulty_var" so i get 395, 390 etc etc

NOW im just STUCK ith this

HOW TO GET THIS FORMULA:

everytime "difficulty_var" lose 5
lifebar width -5
B
41
S
16
G
7
Posts: 1,779
Reputation: 10,029

Post » Mon Jan 30, 2017 5:13 pm

im stuck with this problem, also with the given capx,

what i only need is

HOW TO GET THIS FORMULA:

everytime "difficulty_var" lose -5
lifebar width = -5
B
41
S
16
G
7
Posts: 1,779
Reputation: 10,029

Post » Mon Jan 30, 2017 5:47 pm

HOW TO GET THIS FORMULA:

everytime "difficulty_var" lose -5
lifebar width = -5
and
when "difficulty_var" = 0
then lifebar width = original size
B
41
S
16
G
7
Posts: 1,779
Reputation: 10,029

Post » Mon Jan 30, 2017 6:16 pm

Check your other thread, see if that answers your question. ref: how-do-i-fix-width-size-for-sprite-s_p1095304?#p1095304
Mistakes were made.
B
55
S
28
G
115
Posts: 1,709
Reputation: 65,116

Post » Mon Jan 30, 2017 6:23 pm

well i understand better your example what i need is, when the differents scores in your xample reach 0 they need to restart but with a higher value for example your first valu is 40 when that value reach zero then it need to be 50, when its 0, it need to be 60 etc etc etc
hope you understand :D thanks for helping me :D
B
41
S
16
G
7
Posts: 1,779
Reputation: 10,029

Next

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 21 guests