How to change image on actor b when rule met on actor a

I am very new to GS.
On an options screen I want the user to have the choice between 15 30 60 90 seconds so I created 4 different actors for each option and used a change image to a tick if one is pressed. A game attribute is set to the appropriate value.

Is there a nice way to get rid of the previous tick - i.e. if it's set to 30 and 60 is pressed, I can get the tick on 60 easily, but how do I remove the tick from 30. I could do it by using one actor and variations of a big image that has all settings but wondered if there is a smarter way to do it!

Comments

  • a1000milesa1000miles Member Posts: 36
    Ok - I fixed it by using four separate actors, checking the attribute and displaying the correct image and when any of the actors change the timer setting, I reset the scene. I'm not sure if it's the most efficient way to do it .. but as it is an options screen, I'm not too worried.

    I still would like to hear if there is another smarter way of doing it though :)
  • HopscotchHopscotch Member, PRO Posts: 2,782
    Hi @a1000miles, you say that you have 4 different actors? You could then just add rules in each, e.g. the 15 second actor:

    Rule: when game attribute = 15
    do change image to tick
    else change image to no tick

    repeat this for each actor with the appropriate values.

    Ideally the four actors are just instances of one prototype actor (and maybe this is what you have done). In this case you have 2 options:


    Option 1:

    Add an attribute to the prototype actor, lets say NumOfSeconds.
    Now select each of the 4 instance actors on your scene and change the NumOfSeconds according to its appropriate value.

    Then add a rule to the prototype actor:
    when game.SelectedNumOfSeconds (this you already have) = self.NumOfSeconds
    do change image to tick
    else change image to no tick


    Option 2: (a bit messy but highlights how to access one actor from another)

    Unlock each of the four instance actors, this will give them access to all of the other actors on your scene.

    Now you can build rules to change the image in the other actors from the one touched by changing the attribute under Scene.layers.Actorlayer.actors.actorName.Image




  • HopscotchHopscotch Member, PRO Posts: 2,782
    pffft, you solved it while i was typing :))

    Still have a look at my suggestions, resetting the scene is not elegant ;)
  • a1000milesa1000miles Member Posts: 36
    I tried Option 1 myself but it only changes the tick on that particular actor, it doesn't change the tick on the previously selected option/actor - so I could end up with more than one option showing as ticked :( (although attribute is set correctly).

    The layers thing looks good. I might go see if I can find a youtube video on layers in GS (that's pretty much how I am teaching myself how to do all this!).

    Thanks @Hopscotch .. I appreciate your help.
  • HopscotchHopscotch Member, PRO Posts: 2,782
    Here is an example according to option 1. This is the better option.

    I think it didn't work for you because you probably added the above into your existing touch rule?
  • JfranJfran Member Posts: 10
    when rule on actor A is met, set a boolean attribute to true, if not false. Then, create a rule with actor B: when boolean attribute it true change image to ****
  • a1000milesa1000miles Member Posts: 36
    You are right @Hopscotch .. and when I saw your example, I cringed at how simple it is (once you know how!!). Thanks again.
  • HopscotchHopscotch Member, PRO Posts: 2,782
    Super, glad it helped.
  • a1000milesa1000miles Member Posts: 36
    Thanks for your suggestion too @Jfran.
Sign In or Register to comment.