Citrus-Engine icon indicating copy to clipboard operation
Citrus-Engine copied to clipboard

Feature request: "persistent = true" ( Stops MediatorState from removing these objects automatically on state change )

Open Snky opened this issue 10 years ago • 1 comments

So I want to push the idea of allowing Nape/Box2D to be created only once and not have to be recreated every state change for performance reasons(Adobe Scout agrees with me, this is rather personal but, read below for a solution that could benefit all CE users).

Since the 'physics' (Box2d/Nape) is a CitrusObject, instead of the above request, why not make a persistent:Boolean = false by default in the CitrusObject class. Then the MediatorState will need modifying, to check if 'persistent' is set to 'true', if it is, ignore this object from being deleted when changing state. (To remove a 'persistent' object manually, maybe that "_ce.state.removeImmediately( );" function? This will definitely be important if 'persistent' objects were created, we need a way to remove them)

I got this 'persistent' idea from back in my GameMaker days where an object could exist through as many 'room' changes as you wanted. The great thing is, I understand not everyone will need 'persistent' physics, because their 'next' state may not contain physics objects, simply NOT writing 'persistent = true' on any of your CitrusObjects and it's good for both worlds.

Snky avatar Nov 21 '14 17:11 Snky

Hey, that's a really interesting idea concerning physics engine. For Hero it may be useful too!

It seems to be simple to prevent removing an object from a state. However dealing with its view sound very complicated with the current engine architecture.

alamboley avatar Nov 27 '14 21:11 alamboley