. Topicala Page Index Token

A Journal about the experiences I have developing little applications in C#, Perl, Html and Javascript and talking about things new things that I use. Always Geeky; Always Nerdy; Always poor Grammer!

I am a Software Analyst Developer working in Southport, England but living in Liverpool. I develop mainly in C# and ASP.Net. I have been developing comercial software for several years now. I maintain this site (hosted at SwitchMedia UK) as a way of exploring new technologies (such as AJAX) and just generally talking about techie geek issues. This site is developed through a host of Perl scripts and a liberal use of Javascript. I enjoy experimenting with new technologies and anything that I make I host here.

Quick Search

Web www.kinlan.co.uk

Monday, September 11, 2006

XNA Vector2 Type Converter

I was messing around with the XNA development environment the other day and I started to make a componenet that I thought would be pretty cool to use. I got to the point where my Component had a Vector2 public property that I could use in other components but also change it in the Game Designer.

The only problem was that Vector2 is a struct and doesn't have any way to change the values of the Vector 2 in the designer.

I thought it was about time I started to learn a bit more about type converters, so I created one for this project based on the above problem.

Vector2Converter is a Type convert that should be added to your exposed Vector2 Public Properties. Once you have it on your property, you will be able to change it through the Game Designer using comma notation. i.e you will see it in the designer as {X: 0, Y: 0}, you can change it by typing in something like: 50, 100 which will then convert the output to {X: 50, Y: 100}.

Anyway, I have provided the code [http://www.kinlan.co.uk/source_samples/Vector2Converter.cs] so you can change it for things like Vector3's and the like.


Comments: [Add New]