Events Driven Library XNA C#

Posted by SchautDollar on Game Development See other posts from Game Development or by SchautDollar
Published on 2012-11-21T21:20:53Z Indexed on 2012/11/21 23:12 UTC
Read the original article Hit count: 329

Filed under:
|
|
|
|

Language: C# w/ XNA Framework

Relevant and Hopefully Helpful Background Info: I am making a library using the XNA framework for games I make with XNA. The Library has a folder(Namespace) dedication to the GUI. The GUI Controls inherit a base class hooked with the appropriate Interfaces. After a control is made, the programmer can hook the control with a "Frame" or "Module" that will tell the controls when to update and draw with an event. To make a "Frame" or "Module", you would inherit a class with the details coded in. (Kind of how win forms does it.) My reason for doing this is to simplify the process of creating menus with intractable controls. The only way I could think of for making the events for all the controls to function without being class specific would be to typecast a control to an object and typecast it back. (As I have read, this can be terribly inefficient.)

Problem: Unfortunately, after I have implemented interfaces into the base classes and changed

public delegate void ClickedHandler(BaseControl cntrl); 

to

public delegate void ClickedHandler(Object cntrl, EventArgs e);

my game has decreased in performance. This performance could be how I am firing the events, as what happens is the one menu will start fine, but then slowly but surely will freeze up. Every other frame works just fine, I just think it has something to do with the events and... that is why I am asking about them.

Question: Is there a better more industry way of dealing with GUI Libraries other then using and implementing Events?

Goal: To create a reusable feature rich XNA Control Library implementing performance enhancing standards and so on.

Thank-you very much for taking your time to read this. I also hope this will help others possibly facing what I am facing right now.

© Game Development or respective owner

Related posts about XNA

Related posts about c#