Re: How do I Toggle a VAR on and off? (SOLVED)

Get help using Construct 2

Post » Thu Sep 29, 2016 1:27 am

Ok, this should be simple but I've tried everything I know and I can't get it to work. I'm making an Infinite driving game with my Son (Up and down on the Y) and I want to add a gear shift to the car. So the car is controlled with the arrow keys (up,down,left,right on set to angle, not 8 behavior) I have a VAR called gears and when the up arrow is pressed it adds 1 to the Var and when the down arrow is pressed it subtracts 1. So you start in 1st gear and you can go up to 5 gears each one speeding up or slowing down the speed on the BGRoad Var.

Now what I want to happen is when the Gear Var gets to 5 it stops at that speed level even if you hit the up arrow again it doesn't say 6 or 7 and when it's in 1st gear it stops there. not -1, -2 and so on. The text is set to the VAR so one should fix the other...

Thank you in advance and I hope I explained it properly.

Thanks
Last edited by ALLMarkMade on Thu Sep 29, 2016 9:18 am, edited 1 time in total.
Check out my latest game RAPID-TAPIT. Get your Fingercise on with this one. A steady Tap is all you need to score points. Lift a finger and see what you can do...

Image

ALLMarkMade Designs
B
32
S
15
G
3
Posts: 356
Reputation: 5,269

Post » Thu Sep 29, 2016 2:44 am

On Up Pressed - Set GearVar to min(5,GearVar+1)
On Down Pressed - Set GearVar to max(0,GearVar-1)
Mistakes were made.
B
51
S
25
G
107
Posts: 1,581
Reputation: 60,458

Post » Thu Sep 29, 2016 6:05 am

Thank you I'll let you know. I do appreciate the help.
Check out my latest game RAPID-TAPIT. Get your Fingercise on with this one. A steady Tap is all you need to score points. Lift a finger and see what you can do...

Image

ALLMarkMade Designs
B
32
S
15
G
3
Posts: 356
Reputation: 5,269

Post » Thu Sep 29, 2016 7:29 am

@oosyrag

I appreciate the help but maybe I'm not following or explaining it correctly so maybe this will help.


Image


Image

I need it to stop at 5 (5th Gear) even if you keep left-clicking and stop at 0 (Stop Game) even if you keep right-clicking...

How do I tell the GearsVar not to keep adding or subtracting once it reaches a certain number even if the button is clicked again?

Thank you
Check out my latest game RAPID-TAPIT. Get your Fingercise on with this one. A steady Tap is all you need to score points. Lift a finger and see what you can do...

Image

ALLMarkMade Designs
B
32
S
15
G
3
Posts: 356
Reputation: 5,269

Post » Thu Sep 29, 2016 7:47 am

Remove the the add and subtract actions, and then remove the conditions that compare the gear variable. It should look like what he typed above.
B
92
S
32
G
107
Posts: 5,274
Reputation: 69,959

Post » Thu Sep 29, 2016 8:42 am

@R0J0hound and @oosyrag Thank you both for the help I was coming to mark this solved because what I did was just change the condition from if=5 to if=6 and from if=1 to if= -1 and it seems to work. Now R0J0 if you feel your way is better I will try that so there are no hiccups down the road...

let me know please

Thank you my friends...

After thought, OK I get it! Remove mine and add yours not both correct? Duhhhh OK thanks.
Check out my latest game RAPID-TAPIT. Get your Fingercise on with this one. A steady Tap is all you need to score points. Lift a finger and see what you can do...

Image

ALLMarkMade Designs
B
32
S
15
G
3
Posts: 356
Reputation: 5,269

Post » Thu Sep 29, 2016 9:17 am

THAT WAS IT!!!! Thank You Very Much...
Check out my latest game RAPID-TAPIT. Get your Fingercise on with this one. A steady Tap is all you need to score points. Lift a finger and see what you can do...

Image

ALLMarkMade Designs
B
32
S
15
G
3
Posts: 356
Reputation: 5,269


Return to How do I....?

Who is online

Users browsing this forum: DharmaOne, namaewayukidesu, Yahoo [Bot] and 12 guests