Negative value, positive value

For questions about using Classic.

Post » Sun May 10, 2009 1:07 am

I want to do it:
I have a private variable called HorizontalVelocity and it is equal to 6
I want to change the positive value into negative, or if it was negative (Iqual to -6), convart it into positive.
Using a standard programming language like C/C++, it would be: HorizontalVelocity=-HorizontalVelocity, but I don't know what do I have to write it in Construct (The private variable belongs to a sprite called "Ball"). The action would be "Set value to a private variable", but I don't know what do I have to write in the expression field (It should be an equivalent for HorizontalVelocity=-HorizontalVelocity; in C/C++) :D
Please, I'll be waiting for your help.
Where is Scirra from?. Is Scirra from the United States of America?. I could imagine that Construct is in American English because (Behavior, for example). British English: Behaviour. :D
Bye'!!!
Nicols Matas Funtalas from Buenos Aires, Argentina
:mrgreen:
B
1
G
3
Posts: 4
Reputation: 833

Post » Sun May 10, 2009 1:13 am

i don't have access to construct right now but there should be an "absolute" method which forces values to be positive

abs(value)
absolute(value)

or you can even try the "vertical bar" key (it's to the right of the square/curly brackets)

|value|
B
2
S
2
G
5
Posts: 293
Reputation: 2,236

Post » Sun May 10, 2009 1:19 am

Set velocity to (0 - velocity)
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

Post » Sun May 10, 2009 1:20 am

Set velocity to velocity * -1
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,610

Post » Sun May 10, 2009 1:24 am

[quote="deadeye":1yb9wl4h]Set velocity to (0 - velocity)[/quote:1yb9wl4h]

[quote="Ashley":1yb9wl4h]Set velocity to velocity * -1[/quote:1yb9wl4h]

Either way (they both do the same thing :P )
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

Post » Sun May 10, 2009 1:52 am

-1*HorizontalVelocity

You could also do angle = angle+180, depending on how you're doing your motion.

Scirra is great and the community is really helpful and nice. Welcome!
B
3
S
2
G
4
Posts: 1,445
Reputation: 4,665

Post » Sun May 10, 2009 10:21 am

We're from the UK by the way, not sure why we didn't use '-our'.
B
3
S
2
G
5
Posts: 1,777
Reputation: 5,529


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 9 guests