How to rewind time of SKEmitterNode?

165 Views Asked by At

I'm trying to make particles (implemented with SKEmitterNode) conform to a time rewind feature in a game. How could I achieve this?

From the documentation, it seems that accessing individual particles is not a possible solution and the only property that might be helpful is particleAction. However, I still don't have an idea of how a single action could be used to achieve this.

If this is not feasible, I assume implementing a simpler version of animations from scratch for the game would be necessary. Any suggestions on that would also be greatly appreciated.

1

There are 1 best solutions below

5
Knight0fDragon On

It is ugly, but you may be able to do something like this:

let time = 5
let action = SKAction.customAction(withDuration:time){
                 node,elapsedTime in 
                 guard let emitter = node as SKEmitterNode else {return}
                 emitter.resetSimulation()
                 emitter.advanceSimulationTime(time - elapsedTime)

             }