Click here to Skip to main content
16,021,125 members
Home / Discussions / Game Development
   

Game Development

 
AnswerRe: problem Pin
enhzflep28-Jun-11 9:23
enhzflep28-Jun-11 9:23 
GeneralRe: problem Pin
Thomas Krojer4-Jul-11 21:05
Thomas Krojer4-Jul-11 21:05 
GeneralRe: problem Pin
kevinnicol8-Jul-11 8:09
kevinnicol8-Jul-11 8:09 
AnswerRe: problem Pin
Pravin Patil, Mumbai28-Jul-11 3:07
Pravin Patil, Mumbai28-Jul-11 3:07 
AnswerRe: problem Pin
expert_babaji16-Sep-11 5:43
expert_babaji16-Sep-11 5:43 
QuestionGreat forum, but not much going on... Pin
CDP180223-Jun-11 10:39
CDP180223-Jun-11 10:39 
QuestionRe: Great forum, but not much going on... Pin
AspDotNetDev23-Jun-11 10:58
protectorAspDotNetDev23-Jun-11 10:58 
AnswerRe: Great forum, but not much going on... [modified] Pin
CDP180223-Jun-11 13:03
CDP180223-Jun-11 13:03 
Perhaps I did not describe it well. We started out with ASP .Net pages, a browser game. That already worked well, but it was not really exciting. So we kept the code on the server side, but replaced the presentation part with a client.

WPF would have provided all the GUI we would ever need, but we also wanted to be able to render 3D scenes to make the whole thing a bit more interesting. Making WPF work together with a 3D engine is not easy. You run into very many issues and you can never safely assume that it really works on every computer.

So we ended up adding our own GUI to our XNA graphics engine. We carefully avoided all things which may not be available on the Windows Phone or the XBox, so the whole thing should also safely compile and run for those two. To be honest, we have not yet tested it, but at least in theory we are not limited to the PC.

For all practical reasons the GUI works very much like Windows Forms. You have a Form object and can programmatically add controls or set their properties. Naturally we don't have a designer in Visual Studio because the whole thing is do it yourself. But we can live very well with designing our forms with XAML instead. That is not really hard to do since .Net 4.0

This works very much like XML serialisation and we simply can take a complete form with all its child controls and serialize it to XAML. When the XAML is deserialized again, we get a completely initialized instance of the form with all child controls, properties or even data items as they were before. It's actually only two lines of code, no more.

You probably know how WinForm controls notify their parent forms of events, like buttons raising a OnClick event whenever the user clicks them. In the button's code the event would be declared like this:

public event EventHandler OnClick;


In the form you would find something like this:

Button.OnClick += new EventHandler(SomeMethodOfTheFormToHandleTheEvent); 


Our GUI works exactly the same way. Plain ordinary delegates and event handler methods. The problem is, that the XAML does not contain anything about how the events of the controls and the event handlers are wired together. When we create a new instance of a form by loading the XAML, we get the complete form, but the information about which event handler method handles which control's events has been lost. Delegates and event handler methods are not serializable, so the only way to go is to replace them with something that is. It is possible, since WPF or Silverlight do just that.


Edit:
This is XAML for WPF:
<Button
    OnClick="ButtonClickedHandler" 
    Name="MyButton"
    Width="50"
    Content="Click Me!" /> 


'OnClick' is treated like a normal string property of the button control class. It very probably really is just a string which contains the name of the form's event handler method. Ok, that's not hard to do. My first guess now is, that I must wire up the event after loading the form by finding the event handler method with reflection.
"I just exchanged opinions with my boss. I went in with mine and came out with his." - me, 2011
---
I am endeavoring, Madam, to construct a mnemonic memory circuit using stone knives and bearskins - Mr. Spock 1935 and me 2011



modified on Thursday, June 23, 2011 7:34 PM

AnswerRe: Great forum, but not much going on... Pin
AspDotNetDev23-Jun-11 13:48
protectorAspDotNetDev23-Jun-11 13:48 
GeneralRe: Great forum, but not much going on... Pin
CDP180223-Jun-11 16:07
CDP180223-Jun-11 16:07 
GeneralIf it is of any interest... Pin
CDP180224-Jun-11 11:38
CDP180224-Jun-11 11:38 
AnswerRe: Great forum, but not much going on... Pin
Dalek Dave23-Jun-11 13:19
professionalDalek Dave23-Jun-11 13:19 
GeneralRe: Great forum, but not much going on... Pin
CDP180223-Jun-11 16:15
CDP180223-Jun-11 16:15 
QuestionHey guys, mind telling me what you think of my first actual game with updating of movement? Pin
andyharglesis17-Jun-11 21:05
andyharglesis17-Jun-11 21:05 
AnswerRe: Hey guys, mind telling me what you think of my first actual game with updating of movement? PinPopular
Richard MacCutchan17-Jun-11 22:58
mveRichard MacCutchan17-Jun-11 22:58 
AnswerRe: Hey guys, mind telling me what you think of my first actual game with updating of movement? Pin
Pete O'Hanlon17-Jun-11 23:17
mvePete O'Hanlon17-Jun-11 23:17 
GeneralRe: Hey guys, mind telling me what you think of my first actual game with updating of movement? Pin
andyharglesis18-Jun-11 11:49
andyharglesis18-Jun-11 11:49 
GeneralRe: Hey guys, mind telling me what you think of my first actual game with updating of movement? [modified] PinPopular
enhzflep18-Jun-11 17:40
enhzflep18-Jun-11 17:40 
GeneralRe: Hey guys, mind telling me what you think of my first actual game with updating of movement? Pin
Pete O'Hanlon19-Jun-11 6:47
mvePete O'Hanlon19-Jun-11 6:47 
GeneralRe: Hey guys, mind telling me what you think of my first actual game with updating of movement? Pin
Paul Conrad26-Jun-11 22:16
professionalPaul Conrad26-Jun-11 22:16 
AnswerRe: Hey guys, mind telling me what you think of my first actual game with updating of movement? Pin
Ravi Sant19-Jun-11 22:29
Ravi Sant19-Jun-11 22:29 
GeneralRe: Hey guys, mind telling me what you think of my first actual game with updating of movement? Pin
charles henington21-Sep-24 19:13
charles henington21-Sep-24 19:13 
AnswerRe: Hey guys, mind telling me what you think of my first actual game with updating of movement? Pin
Dalek Dave23-Jun-11 13:18
professionalDalek Dave23-Jun-11 13:18 
GeneralRe: Hey guys, mind telling me what you think of my first actual game with updating of movement? Pin
Pete O'Hanlon23-Jun-11 20:23
mvePete O'Hanlon23-Jun-11 20:23 
GeneralRe: Hey guys, mind telling me what you think of my first actual game with updating of movement? Pin
Dalek Dave23-Jun-11 21:01
professionalDalek Dave23-Jun-11 21:01 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.