effekseer / Effekseer

MIT License
1.48k stars 219 forks source link

In cocos2dx, emitter setPlayOnEnter(false) && setRemoveOnStop (true), will crash when play() #196

Closed wangyin215 closed 5 years ago

wangyin215 commented 5 years ago

In cocos2dx, emitter is created using sample code. But we don't want to play it when add it to scene, so we set emitter -> setPlayOnEnter (false); We add emitter to scene and call emitter -> play () when the button clicks. At this point the program crash out, because emitter has been released(i guess).

So after emitter was created, we tried to set emitter > setRemoveOnStop (false); It's all right now. You can play normally after you click the button.

But we actually want emitter -> setRemoveOnStop (true), because it's easy to do without having to manually handle the issue of remove emitter.

But if emitter -> setPlayOnEnter (false) and emitter - > setRemoveOnStop (true) are set at the same time, calling play by clicking the button will crash the app.

Thank you about the amazing tool.

Hope to answer this question.

wangyin215 commented 5 years ago

Look at this part of Effekseer ForCocos2d-x code

Temporary simple modifications to support this approach

Adding variables to the EffectEmitter class: bool played = false;

Set up in EffectEmitter::play() and EffectEmitter::play(int32_t startTime): played = true;

Modification in EffectEmitter::update(float delta): else if(removeOnStop) to: else if(removeOnStop & played)

durswd commented 5 years ago

I'm sorry for reply. I forget to see this message. Thank you for your information. I will fix this bug after few days.

durswd commented 5 years ago

I fixed bugs including it.

https://github.com/effekseer/EffekseerForCocos2d-x/tree/14x

durswd commented 5 years ago

I released cocos2d-x 1.43c