Cycle color of actor by tapping
wdangelo@me.com
Member Posts: 2
Hey all, as you can tell from the title I am a total noob. What I'd like to accomplish is have the default white box actor cycle through red, blue and green when tapped. I have managed to get the box to change to one color by using the change attribute but I can not figure out how to get it to change to another color when tapped again. I have tried adding another change attribute and rule but that doesn't work either. Any help would be truly appreciated!
Comments
I'd probably do it something like this.
Change the self.Colour attribute to 0 and the default box colour to white if you want to start it as white.
Contact me for custom work - Expert GS developer with 15 years of GS experience - Skype: armelline.support
Here is a simple version:
Make an integer self attribute called ColorState in the actor, then add the following code:
A more flexible version:
Create a table, lets call it T_ColorTable, with three real columns, and a text column. Label each column Red, Blue, Green and the last, Color. Now fill consecutive rows with the red, green and blue color values ( fractions between 0 and 1, e.g. 0.3).
Advantage, easily extendable - just add more rows of colors.
T_ColorTable
Now make an integer self attribute called ColorState in the actor, then add the following code:
MESSAGING, X-PLATFORM LEADERBOARDS, OFFLINE-TIMER, ANALYTICS and BACK-END CONTROL for your GameSalad projects
www.APPFORMATIVE.com
Snap @Armelline
MESSAGING, X-PLATFORM LEADERBOARDS, OFFLINE-TIMER, ANALYTICS and BACK-END CONTROL for your GameSalad projects
www.APPFORMATIVE.com
Here's another version . . .
Real attribute = 'A'.
When touch is pressed:
--Change A to A+120
--Change Red to cos(A)+0.5
--Change Green to cos(A+120)+0.5
--Change Blue to cos(A+240)+0.5
. . . . . . . . .
This cycles through Red > Blue > Green, but if you change the first Change attribute to -120 it will cycle Red > Green > Blue . . . if you change it to +1.40625 it will cycle through an 8bit colour palette (256 colours from Red to Red), or if you change it to +0.00002145767212 you will cycle around the entire 24bit colour palette, although it will take you 16,777,216 clicks to do so ! More usefully, +60 will cycle through Red > Magenta > Blue > Cyan > Green > Yellow > Red . . .
"Crazy Colorful Color Clicker"
Trademarked it yet @Socks? There is a song in there somewhere.
MESSAGING, X-PLATFORM LEADERBOARDS, OFFLINE-TIMER, ANALYTICS and BACK-END CONTROL for your GameSalad projects
www.APPFORMATIVE.com
A song, and an app, and probably a Broadway musical, going to get Danny DeVito to play me.
Thank you all so much! This is extremely helpful!
You could have four different colour boxes and use change image behavior.