24-Oct-2015 15:17
  • Name: Collins Jessica
  • Last online: Today
  • Status:" I'be fuck"
You'll need to login now to contact me
Join Up Free >>

Animations on updating

So when it has rotated a certain amount of degrees/radians then you could set it to scale.Now to keep animation smoothly you will need to use NSTimer Intervals to make sure you multiply the distance moved by time elapsed in order to get smooth animation.

EDIT: The code for doing the second step as you asked!When there are none, the completion block just stops, sort of using them recursively, though this isn't the approach i wouldn't recommend if you are doing a lot of animations on a lot of views continuouly.In Open GLES you use NSTimer to run continuous animation that would handle the updating of all animations in your app.If you go this route its a lot more hard work and you need to implement the easing/quadratic curve functions for smooth animation yourself.However if you extend the clases you could set states for each image and then when the timer fires you could update its transformation based one the states you have given it. Try searching for similar questions Browse our recent questions Browse our popular tags If you feel something is missing that should be here, contact us.

I have a number of images I run continuous animations on. this code block does not cause a smooth scaling, even though it uses [UIView animate With Duration:0.5 delay:0 options: UIView Animation Option Begin From Current State | UIView Animation Option Curve Ease Out //| UIView Animation Option Repeat animations:(void (^)(void)) ^{ image View To Scale.transform = CGAffine Transform Make Scale(1.2, 1.2); } completion:^(BOOL finished){ //image View To Scale.transform=CGAffine Transform Identity; }]; To be honest if your going to have continuous animations on your views that will alter there states at run time UIView animations isn't he best approach and might cause jitter whilst the completion handler is called over and over e.t.c.

How does one update these running animations smoothly so that there is no visible transition between them, unless part of the animation. rotating and scaling an image, and then updating the animation to rotate as it was, but scale up slightly. I can imagine that that scaling should be done within an animation block and them just run the rotation animation as before, the issue would be then that the rotation would stop while it scales up. However is you want to do 2 animations in the block you can either set the scale and the rotation in the same block and they will happend simultaneously.

Or you could call a function that starts the block and on completion calls it again to see if there are any new animations for that view.

So you need to declare a NSTimer that wil poll your animation steps and an NSTime Interval so that you update your animation each step only by the amount of time that has passed.

- (void)start Animation { animation Timer = [NSTimer scheduled Timer With Time Interval:animation Interval target:self selector:@selector(draw View:) user Info:nil repeats: YES]; } - (void)stop Animation { [animation Timer invalidate]; animation Timer = nil; } Then In your draw View: Method you need to update your transforms based on time elapsed between each fire of the timer so that the animation is smooth and constant over time. - (void)draw View:(id)sender { if(last Update Time == -1) { last Update Time = [NSDate time Interval Since Reference Date]; } NSTime Interval time Since Last Update = [NSDate time Interval Since Reference Date] - last Update Time; current Rotation = some Arbitrary SCALEValue * time Since Last Update; current Scale = some Arbitrary ROTATIONValue * time Since Last Update; CGAffine Transform scale Trans = CGAffine Transform Make Scale(current Scale,current Scale); CGAffine Transform rotate Trans = CGAffine Transform Make Rotation(current Rotation * M_PI / 180); image View To Scale.transform = CGAffine Transform Concat(scale Trans, rotate Trans); last Update Time = [NSDate time Interval Since Reference Date]; } Note this will not add easing to your animations nor will it at physics to the stopping you will need to play around with that.

Also you may need to make sure that when the rotation goes over 360 you reset it to 0 and that you convert between degrees and radians respectively.

Profile for animations on updating:

animations on updating-26animations on updating-81animations on updating-18animations on updating-47

Leave a Reply

Your email address will not be published. Required fields are marked *

One thought on “animations on updating”