Quick question regarding OOP and games..

Hi all,

I have never written a game before so I just wanted to clarify one thing.   I am looking at writing a physics based game using OOP (as a learning exercise so that I am more prepared to help my students) and I was just wondering about the usage of frame runtime listeners.  Is it better for;

  1. each class / instance to have its own runtime listener.  I image that this could cause the game to slowdown as more classes called their own listeners?

or

  1. have the runtime listener in the main file (class) and dispatch a custom event after each frame that each class will intern listen for.  I think this is the better method as their is only one runtime listener and one event dispatched (just lost of ears listening).

Am I right in assuming that method 2 is better?

Thanks

Craig

For Runtime (“enterFrame”) events I believe you are better off having only one listener and oing the work there. Of course, you should that work as low as possible and if you are need to update many objects you might want to find other methods. For example, keeping a non-physics animation cloud following a physics object seems like it would require a Runtime listener, but it doesn’t, it only requires adding the animation to the physics object’s display group, possibly another physics object to act as a trail. IMHO, this is one of those easy to learn, hard to master concepts: many people think some things always require a runtime listener. Few actually do. The learning curve is working out how to avoid it effectively.

For Runtime (“enterFrame”) events I believe you are better off having only one listener and oing the work there. Of course, you should that work as low as possible and if you are need to update many objects you might want to find other methods. For example, keeping a non-physics animation cloud following a physics object seems like it would require a Runtime listener, but it doesn’t, it only requires adding the animation to the physics object’s display group, possibly another physics object to act as a trail. IMHO, this is one of those easy to learn, hard to master concepts: many people think some things always require a runtime listener. Few actually do. The learning curve is working out how to avoid it effectively.