Possible to use pool with Actions?

Is it possible to allocate Action objects from a pool?

I’ve looked at the custom allocator stuff added in 3.4 but it doesn’t seem to be possible to use that without modifying the Action classes themselves.

I guess I could subclass MoveTo (or whatever) to make a PooledMoveTo and add the custom allocator bits?

And maybe make actions re-usable? I think you can currently reset the timer maybe back to 0 and use the action manager to restart things, but I believe some of that is declared protected. A pool would be easy with reusable actions since you wouldn’t even need the allocators and could instead just hold an array/vector or other container just like one would do with particles, bullets, or entities for example. So there should be a way to assign a new target and reset its state (and optionally any properties). ?

I’d thought about resettable (and thereby generally poolable) actions but, given a fast fixed-block allocator, the work to construct a new Action object would likely only be a bit more than a reset and has already been implemented so it’s probably good enough. You’d get better cache locality with the allocator as well.

I had the same issue with cocos2d-iphone and ended up rolling my own preallocated resettable action sort-of system. I was hoping 2dx had a better solution but I’ll probably just port the ObjC system over if using the pool allocator is a headache.

Makes sense. I tried the allocator thing and had major issues of crashing and corruption (probably my fault). So once that’s working and I get it working then you’re right. I’d love to just say “make this class alloc in pools”, so I’m excited to give allocators another go during our next engine upgrade.