我有此代碼來顯示一個圖像的動畫動畫圖像序列在cocos2d
-(void) blink:(ccTime) delta {
animateblink ++; //adds 1 every frame
if (animateblink <= 6) { //if we included frames to show for breaking and the current frame is less than the max number of frames to play
if (animateblink < 6) {
[sprite setTexture:[[CCSprite spriteWithFile:[NSString stringWithFormat:@"%@_blinkk00%i.png", baseImageName,animateblink]] texture]];
[self unschedule:_cmd];
[self schedule:@selector(openEyes:) interval:0.1f];
[self schedule:@selector(moveSprite:) interval:0.1f];
}
}
}
我有動畫
dragonimage_blinkk001,dragonimage_blinkk002,dragonimage_blinkk003,dragonimage_blinkk004,dragonimage_blinkk005,dragonimage_blinkk006 like that
的像6個圖像我把兩種方法, 1:動畫時間 2:用於移動圖像
代碼是
-(void) openEyes:(ccTime) delta {
[sprite setTexture:[[CCSprite spriteWithFile:[NSString stringWithFormat:@"%@.png", baseImageName]] texture]];
[self unschedule:_cmd];
int blinkInterval = (arc4random() % 6) + 1; // range 3 to 8
[self schedule:@selector(blink:) interval:blinkInterval];
}
-(void)moveSprite:(ccTime)delta
{
movementCounter ++;
if (movementCounter == 1000) {
[self unschedule:_cmd];
}
else
{
spriteimagename.position = ccp(spriteimagename.position.x+10,spriteimagename.position.y);
}
}
但是在第一種方法中動畫時間不正確,動畫有很多延遲,我只想隨機快速地顯示圖像的動畫,它是一個飛龍動畫。
我在方法上的秒不起作用,我沒有得到任何圖像的運動。
我希望你能理解我的問題。如何解決上述兩個方法問題。 在此先感謝。
您可能希望有HTTP的讀取://www.cocos2d -iphone.org/wiki/doku.php/prog_guide:animation。特別是CCAnimate部分 – 2012-07-16 05:41:14
@Ben我不能這樣做的精靈表的幫助,因爲我需要通過這個值thebaseimagename其他類 – stackiphone 2012-07-16 07:03:28