Issue with menu selection

So I am trying to make an app to help my son communicate what he wants a little better. It will allow us to select up to 3 items or activities and then show pictures that relate so he can point to his choice.

My issue is trying to show that something is selected. I have made two images for a button, one with a blank box, and one with a check mark in the box. I made a Boolean called selected on the actor, and set it as false. I am trying to have it change the image and variable value when touch to show it selected, and on another touch show it as not selected.

When I try it running the debugger window, the image never changes and it lists the variables as true and then false on each click. It seems that is running one rule, then the other immediately. Would adding a timer between the rules help that? If it helps here is a picture of the code in two parts that overlap.

http://i.imgur.com/6OUXK2L.png
http://i.imgur.com/8lrLoD1.png

Comments

  • SocksSocks London, UK.Member Posts: 12,822

    I'd do it like this . . (file attached):

  • SocksSocks London, UK.Member Posts: 12,822
    edited August 2016

    "It seems that is running one rule, then the other immediately."

    Yes, your rule is saying - when touch is released make 'selected' true and false - so it never changes to true. If you think of GameSalad as a calculator, it's being told to add 1 and take away 1 at the same time, the result is nothing changes.

  • BirkelandBirkeland Member Posts: 6

    So does GS treat variables as an absolute value? It looks like you are setting it up so when not selected it changes to -1, and then you subtract 1 again it goes back to zero.

    If that is true, this is a handy solution.

  • SocksSocks London, UK.Member Posts: 12,822
    edited August 2016

    @Birkeland said:
    So does GS treat variables as an absolute value?

    I'm not sure what you mean by an 'absolute value' ?

    @Birkeland said:
    It looks like you are setting it up so when not selected it changes to -1, and then you subtract 1 again it goes back to zero.

    You cannot change an actor (whose condition relies on being touched) without touching it, that is to say you cannot have it do something 'when not selected', not unlike saying a light switch does something when not switched, something can only happen when it is switched ! I hope that makes sense !

    It never changes to -1, it is always either 0 or 1.

    The rule is saying change X to 1-X.

    If X is 0 the result of the equation is 1 (1-0 = 1)
    If X is 1 the result of the equation is 0 (1-1 = 0)

  • BirkelandBirkeland Member Posts: 6

    Yeah, that makes sense. For some reason I was thinking you wrote self.image-1, not 1-self.image, hence my absolute value comment.

    I guess one last question, your solution seems to work because you named the images 1 and 0. I have 6-10 actors on a screen, all of which need to be able to independently switch. Is there an easy way to have one actor trigger a change in another, or would I just need to set a scene variable for each selection, and have the check mark actor look for each variable?

  • SocksSocks London, UK.Member Posts: 12,822
    edited August 2016

    @Birkeland said:
    Yeah, that makes sense. For some reason I was thinking you wrote self.image-1, not 1-self.image, hence my absolute value comment.

    I see what you mean now, there is an absolute function if you need it, it's simply abs(x).

    So . . .

    abs(3) =3
    abs(-3) =3
    abs(-2) =2
    abs(7) =7

    . . etc

    @Birkeland said:
    I guess one last question, your solution seems to work because you named the images 1 and 0. I have 6-10 actors on a screen, all of which need to be able to independently switch. Is there an easy way to have one actor trigger a change in another, or would I just need to set a scene variable for each selection, and have the check mark actor look for each variable?

    I'm not sure what the question is asking ? You seem to be saying 'I need to independently switch the on/off state of each actor - and - can I make them effect each other (non-independence) ?

    Is the first statement related to the question that follows it ?

  • BirkelandBirkeland Member Posts: 6

    Sorry, the first statement was answering your previous comment of

    I'm not sure what you mean by an 'absolute value' ?

    Sorry if that was confusing

    I'm not sure what the question is asking ? You seem to be saying 'I need to independently switch the on/off state of each actor - and - can I make them effect each other (non-independence) ?

    so here is a picture of the screen I am dealing with. Any time one of them is touched I am trying to add the check mark. What I am doing right now is I have the grey box with the file name 1 on the blue box which is its own actor.

    So the way I am handling it is if you touch the blue box labeled pancakes, it changes a scene attribute to be 0. The grey box actor then listens for the scene attribute, and when it is 0 it changes its image to be image 1, the check mark.

    This works, I was just wondering if there was a way to tell the grey box to change its image when the blue button is pushed directly, without having to have a variable for each selection.

  • SocksSocks London, UK.Member Posts: 12,822

    @Birkeland said:
    This works, I was just wondering if there was a way to tell the grey box to change its image when the blue button is pushed directly, without having to have a variable for each selection.

    Would the method I suggested above (change image to 1-image) not work ?

  • BirkelandBirkeland Member Posts: 6

    no, it works. Unless I am misunderstanding, your method works if the names of the images are 0 and 1 right?

  • SocksSocks London, UK.Member Posts: 12,822

    @Birkeland said:
    no, it works. Unless I am misunderstanding, your method works if the names of the images are 0 and 1 right?

    Yes !

  • SocksSocks London, UK.Member Posts: 12,822

    Example attached . . .

  • BirkelandBirkeland Member Posts: 6

    Oh, I see, you just made the buttons and then added the test in GS rather than editing each picture individually. Yeah, that would make a ton more sense and a lot less work.

    Thanks for helping with everything!

Sign In or Register to comment.