I'm trying to figure out an easy way to have a card flip over in a fluid animation without using several animation frames. I tried the fipx property but this is an instantAction and I want a fluid animation for the flip.
Any ideas?
Thanks
A fast, easy to use, free, and community supported 2D game engine
I'm trying to figure out an easy way to have a card flip over in a fluid animation without using several animation frames. I tried the fipx property but this is an instantAction and I want a fluid animation for the flip.
Any ideas?
Thanks
Just a quick thought, but maybe you could try using one of the CCGrid3DAction actions like CCFlipX3D, and halfway through the animation, you could change the spriteframe to the back of the card. If that doesn't work, you might need to write your own Action that flips the card halfway. Then you could just create a CCSequence that would run that action on the card's front-side sprite, and then run the reverse action on the card's back-side sprite.
Thanks, I'll look into this tonight.
Heres some code I wrote for a similar thing.. it flips over a paper sprite which contains a child label sprite and halfway through hides the label giving the illusion it has been turned over.
You can probably condense into just two methods with some show/hide bool parameter.
- (void) flipHide:(CCNode*)node
{
CCEaseExponentialIn* flipHalf = [CCEaseExponentialIn actionWithAction:[CCActionTween actionWithDuration:0.25 key:@"scaleX" from:1.0 to:0.0]];
CCCallFuncN* removeLetter = [CCCallFuncN actionWithTarget:self selector:@selector(hideLetter:)];
CCEaseExponentialOut* flipRemainingHalf = [CCEaseExponentialOut actionWithAction:[CCActionTween actionWithDuration:0.25 key:@"scaleX" from:0.0 to:-1.0]];
CCSequence* seq = [CCSequence actions:flipHalf,removeLetter,flipRemainingHalf, nil];
[node runAction:seq];
}
- (void) flipReveal:(CCNode*)node
{
CCEaseExponentialIn* flipHalf = [CCEaseExponentialIn actionWithAction:[CCActionTween actionWithDuration:0.25 key:@"scaleX" from:-1.0 to:0.0]];
CCCallFuncN* showLetter = [CCCallFuncN actionWithTarget:self selector:@selector(showLetter:)];
CCEaseExponentialOut* flipRemainingHalf = [CCEaseExponentialOut actionWithAction:[CCActionTween actionWithDuration:0.25 key:@"scaleX" from:0.0 to:1.0]];
CCSequence* seq = [CCSequence actions:flipHalf,showLetter,flipRemainingHalf, nil];
[node runAction:seq];
}
-(void) hideLetter:(id)node
{
[[node getChildByTag:kLetterLabel]setVisible:NO];
}
-(void) showLetter:(id)node
{
[[node getChildByTag:kLetterLabel]setVisible:YES];
}
Hope it helps
When to use this both method ? and how ?
- (void) flipHide:(CCNode*)node
- (void) flipReveal:(CCNode*)node
reply soon..
Use them when you need them.
[ flipHide myNode ];
[ flipReveal anotherofmyNodes ];
Hope that was soon enough.
You must log in to post.