2013-12-09 37 views
0

我已經使用CCSequence,但我無法使用CCRepeatForEver。如何脈衝精靈,直到觸摸屏幕上的cocos2d-x爲Android?

CCFiniteTimeAction * S = CCSequence ::動作( CCScaleBy :: actionWithDuration(1,1.0),enter code here CCScaleBy :: actionWithDuration(1,-1.0), CCScaleBy :: actionWithDuration(1,1.0), CCScaleBy :: actionWithDuration(1,-1.0), CCScaleBy :: actionWithDuration(1,1.0), CCScaleBy :: actionWithDuration(1,-1.0),NULL); circle-> runAction(s);

我想在android的cocos2d-x中使用CCRepeatForEver。 請幫助我。

在此先感謝。

回答

1

那麼,你爲什麼不使用它?它不在你的代碼中。還有什麼esxactly做「我無法使用CCRepeatForever」是什麼意思?你有編譯錯誤或運行時?

看着你的代碼,問題是你將一個CCSequence分配給一個CCFiniteTimeAction類型,並且CCRepeatForever需要一個CCActionInterval類型。這是繼承如何去:

CCSequence -> CCActionInterval -> CCFiniteTimeAction -> … 

所以這是完全合法的,做你做了什麼,但不會CCRepeatForever工作,因爲它不知道如何處理您提供的類型做。因此,要使其工作,你需要在兩個地方更改代碼:

CCActionInterval *s = CCSequence::create(…); 
//or 
CCSequence *s = CCSequence::create(…); 
//and at the end 
circle->runAction(CCRepeatForever::create(s)); 

此外,如果你發現,我已經改變了CCSequence::actionsCCSequence::create,因爲這是應該的方式。