Rule and Display Text
Devils
Member Posts: 561
I created a rule within this rule I have a display text behavior whenever the player taps the image the text was suppose to appear then if they tap again its suppose to change to a new text. Two things are happening.
1. I can't get the text to change to another text.
2. I added the text "Peanuts are one of the ingredients in dynamite" but when I go to preview it my image is gone and all I see is a little square in the center of the preview screen. Can someone please help me out?
1. I can't get the text to change to another text.
2. I added the text "Peanuts are one of the ingredients in dynamite" but when I go to preview it my image is gone and all I see is a little square in the center of the preview screen. Can someone please help me out?
Comments
Rule
When Touch is Pressed
----Change Attribute: self.currentText To: self.currentText + 1
Rule
When self.currentText = 1
-----Display Text: "my text 1"
otherwise
-----Rule
-----When self.currentText = 2
----------Display Text: "my text 2"
-----otherwise
----------Rule
----------When self.currentText = 3
---------------Display Text: "my text 3"
etc..
You would use it like this:
Rule
When Touch is Pressed
----Change Attribute: self.currentText To: (self.currentText + 1)%2
That will keep toggling self.currentText to: 0,1,0,1,0,1,0,1.....etc.
Then you would use a Rule, like this
Rule
When self.currentText = 0
.....Display Text: "whatever 1"
otherwise
.....Display Text: "whatever 2"
http://gamesalad.com/forums/topic.php?id=10085
Cheers,
QS
Edit: Joe beat me to it!
Dr. Sam Beckett never returned home...
Twitter: https://twitter.com/Quantum_Sheep
Web: https://quantumsheep.itch.io
What happens when you get to the last one?
So you want an integer attribute in the Actor, called something like 'currentText'.
Every time you click on the Actor, you want to increase self.currentText + 1
So:
Rule
When Touch is Pressed
-----Change Attribute: self.currentText To: self.currentText + 1
If you need it to wrap around back to 0 when you reach the last one, then use the mod function like this:
Rule
When Touch is Pressed
-----Change Attribute: self.currentText To: (self.currentText + 1)%50
Change that '50' to the actual number of texts you have.
Now you need a second set of Rules to display the appropriate text, like this:
Rule
When self.currentText = 0
-----Display Text: "text_0"
otherwise
-----Rule
-----When self.currentText = 1
----------Display Text: "text_1"
-----otherwise
----------Rule
----------When self.currentText = 2
---------------Display Text: "text_2"
etc., etc. for all of the texts that you have.
When you say:
When self.currentText = 0
-----Display Text: "text_0"
What exactly do you mean? I can't find anything in the change attribute that let's me input this statement.