• 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
Simultaneous CoreAnimations
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Simultaneous CoreAnimations


  • Subject: Simultaneous CoreAnimations
  • From: Jeshua Lacock <email@hidden>
  • Date: Sun, 2 Nov 2008 11:20:50 -0700


Greetings,

My flipbook animation is now working - thanks everyone!

I was under the impression that each CoreAnimation operated as an independent thread. However, I created a function that sets the "forKey" property to a unique indentifier each time it is called, and each time it is called it interrupts the current animation and creates a new animation.

I need to be able to play several of the same animations at different locations simultaneously. I can only get it to play in one location at a time.

Can someone please enlighten me how I might accomplish this? Does each animation need its own layer or something? I would hate to have to create a separate function for each possible animation (I have several types of animations and several possible locations).

I am calling my function with:

// X & Y is set to a unique value each time the function is called
int X;
int Y;

[self flipImages:CGPointMake(X,Y)];


The function is:

//Globals
//array populated with UIImages at init
NSMutableArray *images;
CALayer *effectsLayer;


- (void)flipImages:(CGPoint)p {

int i;
CGImageRef im;
UIImage *thisImg;
images = [NSMutableArray array];

for(i = 0;i<[pieces count];i++)
{
thisImg = [pieces objectAtIndex: i];
im = thisImg.CGImage;
[images addObject:(id)im];
}

CAKeyframeAnimation *anim;

NSString *animKey = [NSString stringWithFormat: @"flipper%i.%i", (int)p.x, (int)p.y];

[CATransaction begin];

anim = [CAKeyframeAnimation animation];

anim.keyPath = @"contents";
anim.duration = 1.0;
anim.values = images;
anim.calculationMode = kCAAnimationDiscrete;
anim.repeatCount = HUGE_VAL;


	[effectsLayer setFrame:CGRectMake(p.x,p.y,200.0,180.0)];

	[effectsLayer addAnimation:anim forKey:animKey];

	[CATransaction commit];

}	


Not sure if I should be using CATransaction begin/commit with this type of animation, but it was just something I thought could do the trick.



Thank you,

Jeshua Lacock
Founder/Programmer
3DTOPO Incorporated
<http://3DTOPO.com>
Phone: 877.240.1364

_______________________________________________

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: Simultaneous CoreAnimations
      • From: Jeshua Lacock <email@hidden>
References: 
 >Re: Simple Flipbook Animation? (From: Jeshua Lacock <email@hidden>)
 >Re: Simple Flipbook Animation? (From: Matt Long <email@hidden>)
 >Re: Simple Flipbook Animation? (From: Jeshua Lacock <email@hidden>)

  • Prev by Date: Re: When and how often do you mix C++ with Objective C in your project?
  • Next by Date: Duplicating NSWindow's title bar buttons
  • Previous by thread: Re: Simple Flipbook Animation?
  • Next by thread: Re: Simultaneous CoreAnimations
  • Index(es):
    • Date
    • Thread