I have this strange situation, hope you can help me here because I have 2 days trying to find the solution and I can’t find it.
I made 2 animate actions
for applying to a Sprite
child that also is a Sprite
or a subclass of Sprite
, I initialize them in my init()
Vector<SpriteFrame *> animFrames;
int acc = 0;
for (int i = 0; i < 3; i++, acc += _SMOKE_LOW_ANIM_W){
auto frame = SpriteFrame::create(
_PLAYER_SMOKE_LOW_ANIM_RESOURCE_PATH,
Rect(acc, 0, _SMOKE_LOW_ANIM_W, _SMOKE_LOW_ANIM_H));
animFrames.pushBack(frame);
}
smokeLow = Animate::create(Animation::createWithSpriteFrames(animFrames, 0.2f, CC_REPEAT_FOREVER));
smokeLow->setTag(SMOKEANIM_LOW_TAG);
smokeLow->retain();
animFrames.clear();
acc = 0;
for (int i = 0; i < 3; i++, acc += _SMOKE_HEAVY_ANIM_W){
auto frame = SpriteFrame::create(
_PLAYER_SMOKE_HEAVY_ANIM_RESOURCE_PATH,
Rect(acc, 0, _SMOKE_HEAVY_ANIM_W, _SMOKE_HEAVY_ANIM_H)
);
animFrames.pushBack(frame);
}
smokeHeavy = Animate::create(Animation::createWithSpriteFrames(animFrames, 0.2f, CC_REPEAT_FOREVER));
smokeHeavy->setTag(SMOKEANIM_HEAVY_TAG);
smokeHeavy->retain();
but when I try to use them at the moment needed…
First issue, before run the actions, I have to stop them from the actions list, otherwise I get an assertion error
Assertion failed: (! ccArrayContainsObject(element->actions, action)), function addAction, file /Users/abrajam/Cocos2DX-Projects/SkyHunterTutorial/cocos2d/cocos/2d/CCActionManager.cpp, line 193.
, (this is not a big deal trouble, I can do the stopActionByTag()
and continue with other things, but I really like to know why it happens because in my game I have other Sprites with animate actions
created and executed the same way and they reproduce rightly, I’ve tried to get the target of the Animations before runned and I get a nullptr obviously, so please, help me track this issue).
The second issue is about made them run by the first way, and just shows the first frame of the animation, I tough that was the .png file so I changed to other already working just as a trial, but same error, tried also mading the action a RepeatForever
and instead using the macro CC_REPEAT_FOREVER
on the number of loops the animation is going to reproduce, but same result, I think they do the same.
If I run one Animate
from the init it runs well until I try to change to the other one, also if I run another different action
on the parent the animate on the child gets reproduced by the amount of time the parent action
occurs.