Hello,

It just occurred to me that I probably need my CAKeyframeAnimation declaration to be an array with a capacity to support the maximum number of animations I might have, and then use an available CAKeyframeAnimation to use for each occurrence of the animation. Going to test my theory out now...


On Nov 2, 2008, at 11:20 AM, Jeshua Lacock wrote:


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 (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/jeshua%403dtopo.com

This email sent to [EMAIL PROTECTED]

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

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to