我使用过CCSequence,但我无法使用CCRepeatForEver。
CCFiniteTimeAction * s = CCSequence :: actions(
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(一个或多个);
我想在cocos2d-x中使用CCRepeatForEver for android。 请帮帮我。
提前致谢。
答案 0 :(得分:1)
查看代码,问题是您将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::actions
更改为CCSequence::create
,因为这是应该的方式。