How to get this working using Fast Frame Swap Method

floatingwoofloatingwoo Los Angeles, Calif.Member Posts: 393
edited May 2015 in Working with GS (Mac)

Just starting to get my head around animating using game.time.

In the first screen shot I set up a little morphing animation that loops.Works great.
In the second shot the animation plays through once stopping at the last frame. Also works great.
So I would like to have the animation start (looping) when a touch is pressed. And when pressed again have it stop but only after it has reached the last frame ,so as not to interrupt the loop.


Comments

  • floatingwoofloatingwoo Los Angeles, Calif.Member Posts: 393

    Anybody want to give this a shot? I'm sure it's probably pretty basic but a recent back injury has found me on Tramadol and muscle relaxer and I can't logically think my way out of a box of rocks. Thanks

  • floatingwoofloatingwoo Los Angeles, Calif.Member Posts: 393
    edited May 2015

    Getting close..created a game attribute called pressed. Still not working right ...the goal being when it's reached the last frame , then go through to the end....

  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,880

    Probably something more like this

    When (all)
    game.press = false
    self.Image contains 25
    -- do nothing
    otherwise
    -- Constrain Attribute: self.Image To: "S"..floor( game.Time *20)%25+1

  • RowdyPantsRowdyPants Member Posts: 465

    @RThurman Very cool presentation in the webinar tonight!

    @floatingwoo I would try something like this.

  • floatingwoofloatingwoo Los Angeles, Calif.Member Posts: 393

    Thanks I'll give it a whirl!

  • floatingwoofloatingwoo Los Angeles, Calif.Member Posts: 393

    @RowdyPants Awesome! Works great ...how do I set it up to have it not play till I click on it? Heres a video...
    http://tinypic.com/m/iw3nux/2

    PS: I have a hard drive named FluffyPants

  • SummationSummation Member, PRO Posts: 476
  • floatingwoofloatingwoo Los Angeles, Calif.Member Posts: 393

    @Summation Dang! Nearly dropped little pellets just looking at him....

  • RowdyPantsRowdyPants Member Posts: 465

    @floatingwoo You can just manually set its self.Press to 1 so that initially it won't animate. Is that what you mean?

  • RowdyPantsRowdyPants Member Posts: 465

    @floatingwoo said:
    PS: I have a hard drive named FluffyPants

    Also, <3

  • SocksSocks London, UK.Member Posts: 12,822
    edited May 2015

    @RowdyPants said:
    RThurman Very cool presentation in the webinar tonight!

    floatingwoo I would try something like this.

    I think that's the basic idea although looking at your code I can see two immediate issues, firstly you can make multiple clicks during the loop period - odd numbered clicks (,1,3,5 etc) will stop the loop on the last frame - which is what you want - whereas an even number of clicks will effectively do nothing (the loop will continue to play). The other issue is, that as the animation is synced to game.time, when you restart it by clicking again it will - more often than not - start on an arbitrary frame number (arbitrary to me and you as it's not frame 1).

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

    @RowdyPants said:
    floatingwoo You can just manually set its self.Press to 1 so that initially it won't animate. Is that what you mean?

    If you set 'Press' to 1 the animation will play through and then stop on frame 25 when you first play the project, if you want it to wait for a click to play then you might need some other game switch.

  • floatingwoofloatingwoo Los Angeles, Calif.Member Posts: 393
    edited May 2015

    @Socks Hang with me bro! I really want to understand.

    So the ultimate goal is to have the animation start (looping) after a touch is pressed. And when pressed again have it stop but only after it has reached the last frame. Another touch would repeat the cycle.

    You are correct. With the code the way it is set up now multiple odd numbered clicks stop the loop where I want. Restarting causes a jump from starting on an arbitrary frame.

    What do I want to play with to resolve these issues?

    You mentioned some other game switch?

  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,880

    Hmm....

    This should work:

    Make a boolean attribute called: animate
    Make a real attribute called: startTime

    When:
    Actor Receives Event: Touch is pressed
    -- Change Attribute: self.animate To: not(self.animate)

    When: (All)
    Attribute: self.animate is false
    Attribute: self.image contains 25
    -- do nothing
    otherwise
    -- Change Attribute: self.startTime To: game.Time
    -- Constrain Attribute: self.Image To: "S"..floor(( game.Time-self.startTime)*20)%25+1

  • floatingwoofloatingwoo Los Angeles, Calif.Member Posts: 393

    @RThurman Almost, it's working kinda...but still glitchy...have I got it right?

  • SocksSocks London, UK.Member Posts: 12,822
    edited May 2015

    @floatingwoo said:
    RThurman Almost, it's working kinda...but still glitchy...have I got it right?

    No, you got it wrong ! :smile:

    RThurman: S"..floor(( game.Time-self.startTime)* 20)%25+1
    floatingwoo: S"..floor(( game.Time)* 20)%25+1

  • floatingwoofloatingwoo Los Angeles, Calif.Member Posts: 393

    Ah Thanks, thats working!
    Still it does run through the sequence once when I preview it, without touch is pressed.

  • SocksSocks London, UK.Member Posts: 12,822
    edited May 2015

    @floatingwoo said:
    Ah Thanks, thats working!

    Claims the thanks due to RThurman, sneaks off, doesn't say anything :smile:

    @floatingwoo said:
    Still it does run through the sequence once when I preview it, without touch is pressed.

    Just add in some kind of attribute that says only do these rules once the attribute is triggered.

Sign In or Register to comment.