3 way switch
hiddevandijk
Member Posts: 17
Hi There. I have been searching this forum, but didn't find an answer how to tackle the below:
I'd like to create a 3-way lever controller that controls the movement of a conveyor belt. Something like this:
L--S--R
Where L is left, S is stop, R is right. I want the player to control the motion of the belt by making a swipe movement over this controller. So if the knob is on S and the player swipes to the left the belt goes to the left and vice versa. Again when he swipes to the right the lever snaps into the stop position.
It seems a bit similar to the volume slider tutorial movie, but I want the knob of the lever to snap to the 3 different spots, and not be moving inbetween points.
Any help is most appriciated.
Kind regards,
Hidde.
I'd like to create a 3-way lever controller that controls the movement of a conveyor belt. Something like this:
L--S--R
Where L is left, S is stop, R is right. I want the player to control the motion of the belt by making a swipe movement over this controller. So if the knob is on S and the player swipes to the left the belt goes to the left and vice versa. Again when he swipes to the right the lever snaps into the stop position.
It seems a bit similar to the volume slider tutorial movie, but I want the knob of the lever to snap to the 3 different spots, and not be moving inbetween points.
Any help is most appriciated.
Kind regards,
Hidde.
Comments
Make an integer (or index) attribute. Call it switchState (or whatever makes sense to you).
Make two real attributes. Call call them swipeStartX and swipeEndX respectively.
When touch is pressed
-- Change Attribute: swipeStartX To: game.Mouse Position.X
When touch is released
-- Change Attribute: swipeEndX To: game.Mouse Position.X
--When swipeEndX < game.swipeStartX -20
---- Change Attribute: self.switchState To: max(0, self.SwitchState -1)
--When swipeEndX > game.swipeStartX +20
---- Change Attribute: self.switchState To: min(3, self.SwitchState +1)
--Change Attribute: self.image To: self.switchState..".png"
Note: Using this method, you would need to name the three graphics for the toggle switch to '1.png', '2.png', and '3.png'. 1.png would depict the toggle set to the left. 2.png would depict the toggle set to the middle position. And 3.png would depict the toggle set to the right position.
Have tried many variations, but I either get a looping on/off or stuck on one or the other.
Have two images, one called '0' and one called '1' (no extension, just the number).
In your actor have a rule which says:
When actor is pressed > change self.image to 1-self.image.
Edit: Oops.... @Socks beat me to it again!
In order to obtain the grand prize -- you must complete the original challenge....
Can you use your "no extension" GameSalad voodoo to create a three way toggle switch? (And thus save an innocent integer attribute from life stuck in toggle servitude!)