I've created a CCLayer by using Cocosbuilder. There are two timeline animations called "MyAnim1" and "MyAnim2". None of them are auto-run. MyAnim1 is chained to MyAnim2. I'm using CCBAnimationManager to run the first animation. And it works and the second animation is chained to animation 1 as I expected. But here comes a problem. The first animation goback to its initial status when the second animation start. Is this a bug? Is there a way to keep my first animation status to the end status when the second animation starts?
Related
How can I stop make unity continuous looping
what I have done
1- I add animator to my object.
2- I create animator controller
3- I create my animation
4- finally link my animation controller to my object
it works just fine , but it keep looping
how can I make it animate just once
In your project panel select your animation and in inspector unCheck Loop Time property. That will stop looping your animation :)
Using unity 4.3.4f1.
I started a new project with only one game object on wich I added an animation with 4 sprites. I choosed "Always Animate" from the Animator configuration oon the game object.
When I run the game, the animation play just one time. I see in the animator panel that my animation is replayed again and again because I only have one state. However, Animation won't loop when running the game.
Anyone knows why ?
Sometimes i want to run gif image with animate once or twice,,and stop it,, is there possible to do that?
The animation is controlled by the Animate property of the TGIFImage control. Set it to True to animate, and set it to False to stop the animation.
There is also the AnimateLoop property. If that is True then the animation loops endlessly. Otherwise it runs once and then stops. If you want to run the animation once then set AnimateLoop to False and then set Animate to True.
Finally you have the OnLoop event. That fires each time a looped animation loops back to the start. So, if you want to show an animation twice or more then you need to set AnimateLoop to True and then count the loops in an OnLoop handler.
I make a animation and make it runs it forever. And now I want to stop it after clicking a button. Then animation is rotating a image of a button from 0 to 360 degree.
I'd like to stop the animation but make the animation to finish the current cycle. For example, if the button is rotated at 200 degree, and I click the stop button, I want that the animation still runs to reach 360 degree and then stop.
The animation code is like below:
CABasicAnimation *anim2 = [CABasicAnimation animationWithKeyPath:#"transform.rotation"];
anim2.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];
anim2.fromValue = [NSNumber numberWithFloat:0];
anim2.toValue = [NSNumber numberWithFloat:-((360*M_PI)/180)];
anim2.repeatCount = HUGE_VALF;
anim2.duration = 10;
[self.imgBtn.layer addAnimation:anim2 forKey:#"transform"];
Thanks!
While you can get the animation from the layer using animationForKey:, you cannot modify the animation that way. As the documentation explains it:
Discussion
Attempting to modify any properties of the returned object will result in undefined behavior.
What you instead have to do
You have to remove the infinite animation and add another animation that makes the final end animation.
Use the presentation layer to determine the current rotation of your layer.
Remove the infinite animation
Add a new animation from the value you got from the presentation layer to the end state.
How to get the value from the presentation layer.
During animation your model doesn't change (when using Core Animation). Instead what you see on screen is the layers presentation layer. You can get then read the current value from the presentation layer just as if it was any other layer. In your case you could get the rotation using [myLayer valueForKey:#"transform.rotation"];
Alternately, you can create a single animation with a completion method that triggers the animation again, in an infinite loop.
Have the completion routine check a flag before submitting a repeat.
If the flag is false, don't trigger the animation again.
Then have your button action simply set the repeat flag to false. The current animation will run to completion, and then it won't be repeated.
I've this problem:
in my game, when I tap a sprite, an animation in called. This animation is stored inside a singleton class (called Animation) that is inizialized in the didFinischLaunching method.
When I need for an action i use this code:
[self runAction:[[Animation sharedAnimation] animationName]];
On the device when I tap the sprite for the first time, occurs the following issues (one and only at the first tap):
There is a delay from the moment when I tap the sprite and the moment that the animation really starts;
In this interval (delay) the frame count collapses to 10fps (in some case even to 6fps)
This issues there aren't when I tap the same sprite for a second, third, etc times.
Ideas ??
Thanks very much!
Do you alloc the spriteframes in your animation init method?
If so, that's why.
Good luck!