Hi there my fellow Coronites,
I just started work on a platform shooter (think Sonic or Mario but where the main character can shoot guns and the enemies and bosses can also do this), and I’m wondering about how to tackle my game logic.
I’m using a pseudo-OOP approach, where I spawn a boss-object, and the boss-object spawns bullets every second, and I’m faced with several approaches to bullet collision detection etc. Some of the options are:
- Every bullet that is spawned gets its own Runtime-Enterframe eventListener that detects collisions and if needed kills the player or triggers an explosion. This is neat and clean and very OOP-minded, but would mean creating and destroying loads of eventlisteners on the fly all the time.
- I use one big enterframe eventlistener in my main game loop that iterates over all bullets in existance in that frame. This is probably more efficient but breaks the OOP paradigm that every object contains its own logic - and makes it harder to just adjust the behaviour of one class.
What do you guys do or use? And does anyone know if having massive amounts of enterframe eventlisteners will slow down Corona a lot?
Thanks,
Thomas
p.s. This is my first game adhering to a pseudo OOP standard, modulizing my code, and I have to say the appeal is obvious regarding structure in the code. [import]uid: 70134 topic_id: 27921 reply_id: 327921[/import]