Rule and Display Text

DevilsDevils Member Posts: 561
edited November -1 in Working with GS (Mac)
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?

Comments

  • DevilsDevils Member Posts: 561
    Oh yeah also the text "Hello World" shows up fine.
  • firemaplegamesfiremaplegames Member Posts: 3,211
    I would separate the Rules, like this:

    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..
  • DevilsDevils Member Posts: 561
    firemaplegames said:
    I would separate the Rules, like this:

    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..

    @FMG The top part worked fine but when I get to When self.currentText = 1 it doesn't work do you know what I am doing wrong?
  • DevilsDevils Member Posts: 561
    Is there anyway to loop the text say I only want 2 things to be said but over and over.
  • firemaplegamesfiremaplegames Member Posts: 3,211
    To do that you need to use the mod() function, which is the percent sign: %

    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"
  • quantumsheepquantumsheep Member Posts: 8,188
    This may help:

    http://gamesalad.com/forums/topic.php?id=10085

    Cheers,

    QS :D

    Edit: Joe beat me to it! :D

    Dr. Sam Beckett never returned home...
    Twitter: https://twitter.com/Quantum_Sheep
    Web: https://quantumsheep.itch.io

  • DevilsDevils Member Posts: 561
    Just got home from work I will try these steps and let you guys know how it went. @FMG if this was going to be showing 50-100 text would it also work and how many characters long can my text be? Yesterday when I had it say "Hello World" there where no issues but when I had it say "Peanuts are a ingredient in dynamite" it would not show up also at this exact time when I went to see the preview window there was a small square showing instead of my image. But I will let you know if this turns out any better.
  • DevilsDevils Member Posts: 561
    firemaplegames said:
    To do that you need to use the mod() function, which is the percent sign: %

    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"

    @FMG Either I really am bad at listening to you guys on the forums or just plain dumb. I think my brain is frying from trying this over and over again. Maybe I am not explaining it correctly I am trying to make a image show text when the image is tapped by the player when I try to fix one thing another problem appears. I want to be able to display at least 50-100 text in this image.
  • firemaplegamesfiremaplegames Member Posts: 3,211
    Do these 50-100 texts show up sequentially?
    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.
  • DevilsDevils Member Posts: 561
    Yes they do show up sequentially.

    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.
  • tenrdrmertenrdrmer Member, Sous Chef, Senior Sous-Chef Posts: 9,934
    Have you thought about just making image files with the text you want in each file then use destroy and spawn to cycle through them. If you were worried about memory usage from alot of images you could prob set a scene to cycle through 10 then copy and past the scene and change the images so every 10 (or however many you want) it changes scene and releases some of the memory. Just a thought of a different way to do it. As long as you copy the original scene you are using it would be almost seamless other than the little loading icon every 10 texts
  • DevilsDevils Member Posts: 561
    I can't not for this app. I'm just having issues with the text it keeps showing all the text at once instead of showing them one at a time.
  • tenrdrmertenrdrmer Member, Sous Chef, Senior Sous-Chef Posts: 9,934
    Have you tried save attribute in your rule? Sounds like your attribute is not working right.
Sign In or Register to comment.