[SOLVED] How to move Toggle Left and Right with one click

Get help using Construct 2

Post » Wed Jul 27, 2016 6:20 am

I want to move object left and right in one click
I have try this

when variable is 1 and left click move object 100 pixel left
when variable is 2 and left click move object 100 pixel Right

on any click add 1 to variable
when variable is greater than 2 set value 1
it also not working
please suggest me how to do this
Last edited by luckyrawatlucky on Fri Sep 16, 2016 6:56 am, edited 1 time in total.
Image
B
72
S
41
G
48
Posts: 685
Reputation: 34,286

Post » Wed Jul 27, 2016 6:36 am

It's not working because (probably) your variable will never equal 1 when clicked... since it's adding 1 to itself making it 2.

Do you always want to go left then right, then left then right again? Can you go left, left, left, right maybe? Or can you go right then left?

~Sol
Tired of crappy file hosts that are crappy? Get DROPBOX - https://db.tt/uwjysXJF
Moderator
B
84
S
34
G
40
Posts: 3,032
Reputation: 30,499

Post » Wed Jul 27, 2016 6:50 am

Hi try this,

-On left click + Variable = 1 > set 2 to Variable
- On left click + Variable = 2 > set 1 to Variable

- Left lick down
-+ If Variable = 1 > move left
-+ if Variable = 2 > move right
B
18
S
7
G
1
Posts: 56
Reputation: 3,000

Post » Wed Jul 27, 2016 6:51 am

dieblume86 wrote:Hi try this,

-On left click + Variable = 1 > set 2 to Variable
- On left click + Variable = 2 > set 1 to Variable

- Left lick down
-+ If Variable = 1 > move left
-+ if Variable = 2 > move right


This won't work either... it will set the variable to 1, then immediately to 2.

-On left click + Variable = 1 > set 2 to Variable
- ELSE > set 1 to Variable

^ That would work however.

~Sol
Tired of crappy file hosts that are crappy? Get DROPBOX - https://db.tt/uwjysXJF
Moderator
B
84
S
34
G
40
Posts: 3,032
Reputation: 30,499

Post » Wed Jul 27, 2016 7:07 am

dieblume86 wrote:Hi try this,

-On left click + Variable = 1 > set 2 to Variable
- On left click + Variable = 2 > set 1 to Variable

- Left lick down
-+ If Variable = 1 > move left
-+ if Variable = 2 > move right


I have try this but its not working
check screen
https://www.dropbox.com/s/ygpv4lwbssd7l ... .jpg?raw=1

SoldjahBoy wrote:This won't work either... it will set the variable to 1, then immediately to 2.

-On left click + Variable = 1 > set 2 to Variable
- ELSE > set 1 to Variable

^ That would work however.

This also not worked

but i tried my way which i already explained
I have check in debug mode
variable is changing on every click
1,2,1,2,1,2, so on
but movement is not happening
Last edited by luckyrawatlucky on Wed Jul 27, 2016 7:18 am, edited 1 time in total.
Image
B
72
S
41
G
48
Posts: 685
Reputation: 34,286

Post » Wed Jul 27, 2016 7:15 am

Your image link is wrong... you have linked to your actual dropbox account folder, so unless you want to give out your dropbox credentials so I can log in and see it, you need to link it properly.

The code I posted must have worked... because your variable is changing as expected. Obviously the problem is with how you are making the movement happen based on the the variable value.

~Sol
Tired of crappy file hosts that are crappy? Get DROPBOX - https://db.tt/uwjysXJF
Moderator
B
84
S
34
G
40
Posts: 3,032
Reputation: 30,499

Post » Wed Jul 27, 2016 7:17 am

https://www.dropbox.com/s/ukjr6k6z3toqr ... .jpg?raw=1
this is i have done
and in debug mode
"move" variable is changing on every click
1,2, 1, 2, 1, 2, so on

object moves only once
left then right
and then it stopps


SoldjahBoy wrote:Your image link is wrong... you have linked to your actual dropbox account folder, so unless you want to give out your dropbox credentials so I can log in and see it, you need to link it properly.

Now Links are updated
Image
B
72
S
41
G
48
Posts: 685
Reputation: 34,286

Post » Wed Jul 27, 2016 7:21 am

It's not working because you start with value 0, then it goes to 1 then 2 - then always stays on 2.

It stays on 2 because you add 1 to it's value everytime (so it's at 1 then goes to 2).

Set your value to 0 in event 2.

~Sol
Tired of crappy file hosts that are crappy? Get DROPBOX - https://db.tt/uwjysXJF
Moderator
B
84
S
34
G
40
Posts: 3,032
Reputation: 30,499

Post » Wed Jul 27, 2016 7:27 am

OK OK OK
Thanks now its working
yes I was doing wrong
Image
B
72
S
41
G
48
Posts: 685
Reputation: 34,286

Post » Wed Jul 27, 2016 7:28 am

No problem

~Sol
Tired of crappy file hosts that are crappy? Get DROPBOX - https://db.tt/uwjysXJF
Moderator
B
84
S
34
G
40
Posts: 3,032
Reputation: 30,499

Next

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 8 guests