How to get this working using Fast Frame Swap Method
floatingwoo
Los Angeles, Calif.Member Posts: 393
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
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
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....
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
@RThurman Very cool presentation in the webinar tonight!
@floatingwoo I would try something like this.
Thanks I'll give it a whirl!
@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
Mathtap.com (Android) | Fridgemanager.com (Android) | Breakoutofspace.com (Android)
@Summation Dang! Nearly dropped little pellets just looking at him....
@floatingwoo You can just manually set its self.Press to 1 so that initially it won't animate. Is that what you mean?
Also,
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).
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.
@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?
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
@RThurman Almost, it's working kinda...but still glitchy...have I got it right?
No, you got it wrong !
RThurman: S"..floor(( game.Time-self.startTime)* 20)%25+1
floatingwoo: S"..floor(( game.Time)* 20)%25+1
Ah Thanks, thats working!
Still it does run through the sequence once when I preview it, without touch is pressed.
Claims the thanks due to RThurman, sneaks off, doesn't say anything
Just add in some kind of attribute that says only do these rules once the attribute is triggered.