主要采用CCOrbitCamera摄影机功能实现
-(void) testFlipCard
{
// create a sprite
CCSprite *sprite1 = [CCSprite spriteWithFile: @"c1.png"];
// set position of the sprite
[sprite1 setPosition: ccp(240.0f, 160.0f)];
// create an action
id actionFunc1 = [CCSequence actions:
[CCDelayTime actionWithDuration: 0.5f],
[CCCallFuncN actionWithTarget: self selector: @selector(testFlipCardCallFunc1:)],
[CCDelayTime actionWithDuration: 1.0f],
[CCCallFuncN actionWithTarget: self selector: @selector(testFlipCardCallFunc2:)],
[CCDelayTime actionWithDuration: 0.5f],
nil];
id actionFlip1 = [CCOrbitCamera actionWithDuration: 2.0f
radius: 1.0f
deltaRadius: 0.0f
angleZ: 0.0f
deltaAngleZ: -360.0f
angleX: 0.0f
deltaAngleX: 0.0f];
id actionForever1 = [CCRepeatForever actionWithAction: [CCSpawn actions:
actionFunc1, actionFlip1, nil]];
// run action
[sprite1 runAction: actionForever1];
// add the sprite to the layer
[self addChild: sprite1];
// create a sprite
CCSprite *sprite2 = [CCSprite spriteWithFile: @"c0.png"];
// set position of the sprite
[sprite2 setPosition: ccp(240.0f, 160.0f)];
// hide sprite 2
[sprite2 setVisible: NO];
// create an action
id actionFunc2 = [CCSequence actions:
[CCDelayTime actionWithDuration: 0.5f],
[CCCallFuncN actionWithTarget: self selector: @selector(testFlipCardCallFunc2:)],
[CCDelayTime actionWithDuration: 1.0f],
[CCCallFuncN actionWithTarget: self selector: @selector(testFlipCardCallFunc1:)],
nil];
id actionFlip2 = [CCOrbitCamera actionWithDuration: 2.0f
radius: 1.0f
deltaRadius: 0.0f
angleZ: 0.0f
deltaAngleZ: -360.0f
angleX: 0.0f
deltaAngleX: 0.0f];
id actionForever2 = [CCRepeatForever actionWithAction: [CCSpawn actions:
actionFunc2, actionFlip2, nil]];
// run action
[sprite2 runAction: actionForever2];
// add the sprite to the layer
[self addChild: sprite2];
}
-(void) testFlipCardCallFunc1 : (id) node
{
[node setVisible: NO];
}
-(void) testFlipCardCallFunc2 : (id) node
{
[node setVisible: YES];
}