How to make and actor repeat and action with out using spawn?

jobeijobei Member Posts: 39
edited June 2012 in Working with GS (PC)
To let you know what's going on in my game, I have it when i tap on a box 2 times, it turns the background different colors, but I just want to able to tap on the box one time and it go to the next color.

I dont want to use spawn.

Best Answers

  • gyroscopegyroscope I am here.Posts: 6,598
    Accepted Answer

    Hi @jobei

    To answer your question, a bit more detail is needed:

    Are you saying that if you tap twice, close together, it turns the background a different colour compared with when you tap it just once? And are there specific colours, and order of colours, or are you after random coloured backgrounds?

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • gyroscopegyroscope I am here.Posts: 6,598
    edited June 2012 Accepted Answer

    OK, I think I see what you mean: I guess you're using a Timer to "judge" the two taps, and an attribute that when it's 2, the background colour changes?

    If that's correct, then just get rid of those Rules; so in your Actor A, all you need for it to change the background with one tap is:

    When touch is pressed
    Change Attribute scene.Background.BackActor.Color.Green to 0
    Change Attribute scene.Background.BackActor.Color.Blue to 0

    >>>> If needed: Timer, after 1 second
    Interpolate Attribute scene.Background.BackActor.Color.Green to 1, duration, say 1 second or whatever you want
    Interpolate Attribute scene.Background.BackActor.Color.Blue to 1, duration, say 1 second or whatever you want

    Try that, see if that's what you're after....

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • gyroscopegyroscope I am here.Posts: 6,598
    edited June 2012 Accepted Answer

    OK, I see what's going on: basically the Rules:

    actor A:
    touch is pressed:
    do:
    change attribute: set: game.neagtive image2
    to: (game.negative image2+1)%2

    is toggling between two values, i.e 1 and 2 (or 0 and 1). But Actor B only does its stuff when the value is 1; so it'll only work every other time.

    In this case, the Rules can be amended but it'll just make it unnecessarily complicated, so it's best that you ditch those Rules, in this case. And then you can put all the control stuff in the one actor - the one you press, i.e Actor A. Make sure its unlocked then put the following into Actor A's Rules, and you should be good to go:

    When touch is pressed
    Change Attribute scene.Background.ActorB.Alpha to 1
    Interpolate scene.Background.ActorB.Alpha to 0 Duration 5 seconds

    You can put a Timer in to delay it before the fade starts if you want, so instead the Rules would be:

    When touch is pressed
    Change Attribute scene.Background.ActorB.Alpha to 1
    Timer: After 2 seconds
    Interpolate scene.Background.ActorB.Alpha to 0 Duration 5 seconds

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

Answers

  • jobeijobei Member Posts: 39
    ok I have one box actor A , and actor B is the background color. when I tap actor A twice the background color change to red then fade back to the normal color white. but I just want to be able to tap the actor A once to change the background color.

  • jobeijobei Member Posts: 39
    no I'm not using a timer but if i could that would be nice I dont know how to make that work in the code.
    This is the code Im using now:
    actor A:
    touch is pressed:
    do:
    change attribute: set: game.neagtive image2
    to: (game.negative image2+1)%2

    actor B:

    if game.negative image2 = 1

    do:
    change attribute set: self.color.alpha
    to: 1

    interpolate: self.color.alpha
    to: 0
    for: 5
    linear

    I think the reason I have to tap on actor A twice is because of the +1)%2
    I just want to be able to tap on actor A one time over and over again to get the negative color I made to pop up back to back each time i tap the actor A.

  • jobeijobei Member Posts: 39
    Thanks, I got it now! : )
Sign In or Register to comment.