• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: CALayer: Animation using actions property
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: CALayer: Animation using actions property


  • Subject: Re: CALayer: Animation using actions property
  • From: "Bhatnagar, Arvin" <email@hidden>
  • Date: Tue, 19 Apr 2011 12:26:58 -0400
  • Acceptlanguage: en-US
  • Thread-topic: CALayer: Animation using actions property

Ok that worked if I were animating just one layer on its own. However, I am animating three separate layers in sequence to one another. I know we can group multiple animations for one layer (CAGroupAnimation). Other than using a timer, is there an alternative to coordinating the animation of different layers?

Some Code:

- (void) moveDots {



    // Animate Dot Opacity

    CALayer* dot = (CALayer *)[mDotLayers objectAtIndex:mDotPosition];

    dot.opacity = mDotDirection ? 0.0f : 1.0f;

    [self setNeedsDisplay];



    // NO --> Forward, YES <-- Backward

    if ( !mDotDirection ) mDotPosition++;

    if (  mDotDirection ) mDotPosition--;



    if ( mDotPosition < 0 ) {

        mDotPosition = 0;

        mDotDirection = NO;

    }



    if ( mDotPosition > (_noOfDots-1) ) {

        mDotPosition = (_noOfDots-1);

        mDotDirection = YES;

    }

}


- (void) _startAnimationTimer {


    // Just in case

    [self _stopAnimationTimer];



    // Dot Layer Timer

mDotTimer = [NSTimer timerWithTimeInterval:(NSTimeInterval)1.0f

                                        target:self

                                      selector:@selector(moveDots)

                                      userInfo:nil

                                       repeats:YES];

    [mDotTimer setFireDate:[NSDate date]];

    [[NSRunLoop currentRunLoop] addTimer:mDotTimer forMode:NSRunLoopCommonModes];

    [[NSRunLoop currentRunLoop] addTimer:mDotTimer forMode:NSDefaultRunLoopMode];

    [[NSRunLoop currentRunLoop] addTimer:mDotTimer forMode:NSEventTrackingRunLoopMode];

}


Thanks,

Arvin

On 4/19/11 12:07 PM, "Bhatnagar, Arvin" <email@hidden<mailto:email@hidden>> wrote:

Thanks David, I am going to try that suggestion right now.

On 4/19/11 11:59 AM, "David Duncan" <email@hidden<mailto:email@hidden>> wrote:

On Apr 18, 2011, at 7:49 PM, Bhatnagar, Arvin wrote:

This is probably a simple question for someone other than I.
I have a very simple CALayer which is a simple plain layer with a white
background. I then create a CABasicAnimation and add it to the actions
property to animate the @"opacity". From here I setup a timer to fire
and toggle the opacity between 0 and 1 which animates.


Your analysis of the timer was correct, but I wanted to talk to this
point instead ­ rather than using a timer to toggle the opacity, you
could just add an animation to the layer that auto-reverses and repeats
indefinitely, which would likely give you the same effect without having
to run a timer at all.
--
David Duncan


_______________________________________________

Cocoa-dev mailing list (email@hidden<mailto:email@hidden>)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden<mailto:email@hidden>

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: CALayer: Animation using actions property
      • From: David Duncan <email@hidden>
References: 
 >Re: CALayer: Animation using actions property (From: "Bhatnagar, Arvin" <email@hidden>)

  • Prev by Date: Re: CALayer: Animation using actions property
  • Next by Date: Re: CALayer: Animation using actions property
  • Previous by thread: Re: CALayer: Animation using actions property
  • Next by thread: Re: CALayer: Animation using actions property
  • Index(es):
    • Date
    • Thread