CCSprite with actions crossing the screen boundaries (copy sprite problem)

Posted by iostriz on Stack Overflow See other posts from Stack Overflow or by iostriz
Published on 2010-06-09T11:19:33Z Indexed on 2010/06/09 11:22 UTC
Read the original article Hit count: 430

Filed under:

Let's say we have a CCSprite object that has an actions tied to it:

-(void) moveJack
{
    CCSpriteSheet *sheet = (CCSpriteSheet*)[self getChildByTag:kSheet];
    CCSprite *jack = (CCSprite*)[sheet getChildByTag:kJack];
...

    CCSequence *seq = [CCSequence actions: jump1, [jump1 reverse], jump2, nil];
    [jack runAction:seq]; 
}

If the sprite crosses over the screen boundary, I would like to display it at opposite side. So, original sprite is half displayed on the right side (for example), and half on the left side, because it has not fully crossed yet. Obviously (or is it), I need 2 sprites to achieve this. One on the right side (original), and one on the left side (a copy). The problem is - I don't know how to create exact copy of the original sprite, because tied actions have scaling and blending transformations (sprite is a bit distorted).

I would like to have something like:

CCSprite *copy = [[jack copy] autorelease];

so that I can add a copy to display it on the correct side (and kill it after transition is over). It should have all the actions tied to it...

Any ideas?

© Stack Overflow or respective owner

Related posts about cocos2d-iphone