Distance Measured with Arrow Keys

Get help using Construct 2

Post » Sun Feb 15, 2015 5:00 am

Hi all, so I am learning the basics of movement and measure. I have a box just moving down and up from the roof to the floor. I have a (every tick) text set to display the distance from origin (the roof, a solid impassable object) I have the keyboard function when key pressed down (arrow key) add 1 to global distance. When I play the game, the box moves down from the roof and this number takes off fast, so I changed it to add 0.01 (global) instead of 1 which makes it more realistic. So say the box moves down 10 in distance hits the floor (another impassable object) But my trouble is the numbers continue when the box collides with the floor or roof. I have subtract 0.01 for moving back up. Is there a way to set a threshold for numbers so when they reach say 0 or 10 they will stop counting even if the up or down key is pressed. In a nutshell imagine a box moving down from the roof starting at 0 hits the floor at 10 then moves back up to the roof at 0 with these numbers in the HUD. Thank you in advance! One more thing, lol, can you make the count slower or do I have to stick with the 0.01. Thanks again for all your guys help!
B
19
S
10
G
1
Posts: 24
Reputation: 2,203

Post » Sun Feb 15, 2015 10:31 am

Hey Trailbike,

It sounds like you want to compare the variable changing the speed. If your condition is "When key down add to speed", you just have to add another condition that makes sure the speed (or number) isn't over the amount you want it to go over.

Here is an example.
You do not have the required permissions to view the files attached to this post.
ImageImage
B
89
S
18
G
6
Posts: 1,049
Reputation: 11,165

Post » Sun Feb 15, 2015 11:33 am

you can add when if keyisdown and number is less or equal to some number add 1 to the number if its not equal or less just do the oposit, and should automatically stop adding numbers if u have a capx example to share we can understand better what u need to do, i think its just a matter of conditions u need to setup, cause as u said it doesnt stop when u are on top or bottom of roof, so that means u dident told the system to stop if the number is at end (therefore u need to know the length of the roof u travel)
Image
B
62
S
19
G
67
Posts: 1,310
Reputation: 41,938

Post » Sun Feb 15, 2015 10:43 pm

Thanks GenkiGenga and gamecorpstudio. @ gamecorpstudio, yes I did this like you said and also added when I have the box collide with the roof this event will reset the global variable keeping it at 0 and set the greater then for the floor. This is what I got and it works pretty good! Thanks again, you guys rock. @GenkiGenga, now I will work on the speed variable and make some fine adjustments. I have shared the file with you of my progress.
You do not have the required permissions to view the files attached to this post.
B
19
S
10
G
1
Posts: 24
Reputation: 2,203


Return to How do I....?

Who is online

Users browsing this forum: DrKoala, GoodCat and 6 guests