Simple Key on, off and on again...!
Guido
Member Posts: 12
Hi, I can not get a simple operation with GS. I want to create
a button-shaped bulb. When the button is not pressed is
off, stays on when pressed. If I press it again
off.
So: button is Off > touch and becomes On.
button is On > touch and becomes Off.
You have solutions on this?
I tried this way but not working as it should:
Rule: "Actor receives event" "touch" is "Pressed"
Change Image: "Set Image to: bulb_on.png
Rule: "Actor receives event" "touch" is "Released"
Change Image: "Set Image to: bulb_off.png
thanks!
a button-shaped bulb. When the button is not pressed is
off, stays on when pressed. If I press it again
off.
So: button is Off > touch and becomes On.
button is On > touch and becomes Off.
You have solutions on this?
I tried this way but not working as it should:
Rule: "Actor receives event" "touch" is "Pressed"
Change Image: "Set Image to: bulb_on.png
Rule: "Actor receives event" "touch" is "Released"
Change Image: "Set Image to: bulb_off.png
thanks!
Comments
Attribute called onoff.
When touch is pressed and when self.onoff is true, change attribute to false, change image (to off version).
When touch is pressed and when self.onoff is false, change attribute to true, change image (to on version).
:-)
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps
First
When actor receives touch change attribute onOff to (onOff +1)%2. This will cause the value to switch between 0 and 1.
After that create another rule. When onOff is 0 change image to off.png otherwise change to on.png
That should work
Send and Receive Data using your own Server Tutorial! | Vote for A Long Way Home on Steam Greenlight! | Ten Years Left
Rule
When touch is pressed
Change attribute self.switch to (self.switch +1)%2
New rule when self.switch = 0
do blah blah
Otherwise
Do blah blah blah
EDIT: didn't read mulcahy's post closely! Like he said
on touch
self.switch to (self.switch+1)%2
self.image to self.switch .. self.file (where self.file is a text attribute with .png)
Change Attribute: self.Image to: self.switch..".png"
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps
http://gamesalad.com/forums/topic.php?id=86#post-328
good luck!
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps