so this is the very simple showcase: I have a object
gameobject
- particlefx
- script
then in the script i have:
function init(self)
particlefx.play("#particlefx")
particlefx.stop("#particlefx")
end
then the particlefx.stop call is ignored, the particlefx start emitting and wont stop.
I made some attempts and discovered:
particlefx.stop only works when the its state is particlefx.EMITTER_STATE_SPAWNING , that’s why the above call is not working.
after particlefx.start, the state changes to particlefx.EMITTER_STATE_SPAWNINGin the NEXT frame, then I have to call particlefx.stop in another next frame to surely stop it.
What I want to ask is, is this in line with the design?
my actual situation is that when a buff is added, particle effects need to be started, and when the buff is removed, stop the particle effects. In some cases, this addition and removal can occur within a single frame.
I would say this is a bit of an edge case. It should be fairly trivial to handle this case of starting and stopping in the same frame, but I am not able to check the code right now. Please open a feature request on GitHub!
Seems a bit strange to want to run a particle effect for a zero amount of time.
I am not sure, but I think you are after some sort of side effect of doing this; if so clearly not a good idea to have to do. I confess that I don’t really know what you are looking to achieve, even after reading this bit:
In general, our stance is that if the user can easily check for it, then we avoid implementing it.
Remember that every feature request increases the engine size. And it’s one of our major selling points.
more specifically, I have a BuffSystem that handles the attach, update, and detach events for each Buff. The control of particle effects is managed within the attach and detach phases, which works fine in most cases. However, due to the limitation I mentioned above, if a buff’s duration logic lasts less than two frames, the particle effects will display incorrectly.
You might wonder why a buff with such a short duration would need a visual effect. In fact, I’m developing a traditional roguelike game where, in each frame, I try to process turn-based logic for as much Actors (core logic similar to this article) . As a result, it’s possible for a buff that is supposed to last multiple turns to be fully resolved within a single frame.
currently i avoid this issue by introducing a timer.delay, but I feel this might be an edge case that the particlefx.stop interface should handle.
understood.
my point is that this would only be handling an edge case without introducing new interfaces or maintenance overhead. moreover, implementing this check isn’t actually straightforward—it would require passing a callback into particlefx.play to track the state.
however, the decision is yours.