0
我想延遲添加到一個精靈,所以當我進入一個新的場景它不打直線距離,任何建議將不勝感激感謝時間延遲,cocos2d的
繼承人的精靈的代碼,如果有幫助
//SPRITES BIRD ONE -------------------------
//------------------------------------------
CCSpriteFrameCache *cache=[CCSpriteFrameCache sharedSpriteFrameCache];
[cache addSpriteFramesWithFile:@"house-ipad.plist"];
// frame array
NSMutableArray *framesArray=[NSMutableArray array];
for (int i=1; i<24; i++) {
NSString *frameName=[NSString stringWithFormat:@"house-ipad%d.png", i];
id frameObject=[cache spriteFrameByName:frameName];
[framesArray addObject:frameObject];
}
// animation object
id animObject=[CCAnimation animationWithFrames:framesArray delay:0.035];
// animation action;
id animAction=[CCAnimate actionWithAnimation:animObject restoreOriginalFrame:NO];
//id animAction=[CCAnimate actionWithDuration:4 animation:animObject restoreOriginalFrame:NO];
//animAction=[CCRepeatForever actionWithAction:animAction];
// sprite (width,height)
CCSprite *bird=[CCSprite spriteWithSpriteFrameName:@"house-ipad1.png"];
bird.position=ccp(550,470);
// batchNode
CCSpriteBatchNode *batchNode=[CCSpriteBatchNode batchNodeWithFile:@"house-ipad.png"];
[self addChild:batchNode];
[batchNode addChild:bird];
[bird runAction:animAction];
//-----------------------------------------
嘗試搜索'NSTimer'。我確定有一些關於使用它的教程。 – evotopid 2012-01-07 09:37:20