--- On Mon, 8/10/09, DairyKnight <[email protected]> wrote:

From: DairyKnight <[email protected]>
Subject: AtlasSprite & Animation problem - Causing BAD_EXEC ?
To: "cocos2d discuss" <[email protected]>
Date: Monday, August 10, 2009, 5:46 PM



I'm trying to figure out how the AtlasSprite & Animation works. I
studied the sample
projects and coded my own, but it seems the code creating the
animation object
cannot be 'separated' from the code calling the actions. e.g. :

In -(void) init
mgr = [AtlasSpriteManager spriteManagerWithFile:@"knight.png" capacity:
50];
        knight = [AtlasSprite spriteWithRect:CGRectMake(0, 90, 90, 90)
spriteManager:mgr];
        knight.position = ccp(400, 160);
        [mgr addChild:knight];
        [self addChild:mgr];

        animation = [AtlasAnimation animationWithName:@"walk" delay:0.2];
        for (int i = 0; i < 3; i++)
        {
            [animation addFrameWithRect:CGRectMake(i * 90, 90, 90, 90)];
        }
        atlasSpriteAction = [Animate actionWithAnimation:animation];
        [knight runAction:[RepeatForever
actionWithAction:atlasSpriteAction]];

Would just work fine. but if you write:

In -(void) init:
mgr = [AtlasSpriteManager spriteManagerWithFile:@"knight.png" capacity:
50];
        knight = [AtlasSprite spriteWithRect:CGRectMake(0, 90, 90, 90)
spriteManager:mgr];
        knight.position = ccp(400, 160);
        [mgr addChild:knight];
        [self addChild:mgr];

        animation = [AtlasAnimation animationWithName:@"walk" delay:0.2];
        for (int i = 0; i < 3; i++)
        {
            [animation addFrameWithRect:CGRectMake(i * 90, 90, 90, 90)];
        }

In -(void) onEnter:
        atlasSpriteAction = [Animate actionWithAnimation:animation];
        [knight runAction:[RepeatForever
actionWithAction:atlasSpriteAction]];

The program crashes. But by putting all the above code in -(void)
onEnter would work fine as well. This looks a little bit unreasonable
to me. Isn't it possible to pre-build an animation/action object and
use it at a later time?

Hope somebody knows the answer. Thanks in advance.




Can you send all the project in a zip file to me :P it seems that this code is 
writen very good your problem isn`t in this code i think



      
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"cocos2d discuss" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/cocos-discuss?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to