Trying to get different actors to change images on the same scene
waterjunky
Member Posts: 3
I am new to GS and trying to figure out how to do something that seems like it should be simple to do in one scene rather than referencing many different scenes. I have 20 button actors, which I want to show a different image next to the buttons on touching each button. When a button is pressed, then an image should appear next to the buttons, the button that was pressed becomes highlighted. When a different button is pressed then a different image should replace the last image that appeared, the last button that was highlighted resets to OFF (image), then the new button is highlighted ON (image). I know you can spawn an actor on press of a button, but how do you destroy that spawned actor once another button is pressed to spawn a different actor (or image)? And, how do you change the button highlighting mentioned above? Can this be done all in the same scene or does it need to be separated in 20 different scenes?, i.e. when different button is touched then it goes to another scene to show the related image.
Answers
http://forums.gamesalad.com/discussion/57734/how-to-change-image-on-actor-b-when-rule-met-on-actor-a#latest
The actor which is used to generate the big image has a rule which sets the image depending on an attribute value which is set by each button.
Something like ..
when apple button is pressed, change attribute big_image to 1 (big apple)
when orange button is pressed change attribute big_image to 2 (big orange)
when pear button is pressed change attribute big_image to 3 (big pear)
When the buttons are pressed, they spawn a separate big image actor which
checks the attribute and then uses change image to set the right image
The big_image actor could be destroyed after a specific time, ready for the next button to be pressed.
The small buttons could also use a change image to the "highlighted" version and if necessary get switched back using the same timer as the destroy big image actor.
Not sure if I understand what you are trying to do correctly, so hope this helps.
So, here's what I ended up with, which works for me:
After positioning instances of the same actor for the thumbnail buttons and the actor for the larger image, add the following rules for each of the thumbnail actors in the scene: In a Rule for touch is pressed - Change Attribute/Current Scene/layers/select the name of the Actor where the larger image will appear. To: the name of the image.