[C#] Using XNA In Windows Forms

Perfect starting ground for a map editor

Page 1 of 1

0 Replies - 5392 Views - Last Post: 16 July 2008 - 09:54 AM Rate Topic: -----

#1 NickCosentino   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 16-July 08

[C#] Using XNA In Windows Forms

Posted 16 July 2008 - 09:54 AM


After searching endlessly for an example in C# on how to get XNA to render 2D graphics in a windows form,
I decided I should try my hand at it all by my lonesome. It took me a while to figure it out, mainly because
when I finally had the graphics device rendering to the correct location, my bitmaps were just solid colours
instead of the correct graphics. So I kept playing with it until finally I got something.

The idea behind it is that you use a normal XNA game project, and then pass the Sprite Batch, Graphics Device,
and Content Manager to your windows form. Then you put a draw loop on the form, and tell the device to
draw to a panel instead of the game window.

If what I said was confusing, take a peak at the code. It's very simple (if you have a bit of experience with basic
programming) and should be a great starting point for anyone who wants to make a level editor (which is why I
stumbled across this in the first place!)

I'm assuming I'm posting this in the correct forum since map editors and XNA are game related, but if it's in the
wrong spot, my apologies (this just seemed the most suitable place).

This project was created as a basis for my map editor for my game Macerus, which I am currently developing on
my own using the XNA framework. Here's a link to the site where you can download the XNA In Windows Form


Hope this can be of some use!

Is This A Good Question/Topic? 0
  • +

Page 1 of 1