bballmitch

When I use the basic Xna game template, Microsoft sets the origin (0,0) to the top right corner of the window. Is there a way to make the origin the center of the screen (without translating everything I draw 400 pixels to the right and 300 pixels down)


Re: XNA Framework Altering the Origin when using Xna

Darkside

in 2D the Origin is the Top Left, in 3D it is the centre of the screen, thats just how things are.

Simplest way of having a different origin is to hold to variables for the screen offset for the centre, the best way to set the offset automatically is to use the GraphicsDevice.Viewport settings for with and height and divide each by 2.

Hope this helps

Darkside






Re: XNA Framework Altering the Origin when using Xna

irishcoder

Would it be a major drain on speed to wrap a vector2 in a class called myVector2 and let it do all the translation you need and have it output a vector2 for use in xna calls

i.e
myVector2 test=new myVector2(100,50)

spritbatch.draw(mytex,test.adjVector2  etc...






Re: XNA Framework Altering the Origin when using Xna

Darkside

That would be fine so Long as you kept the offset in a STATIC class or Global class somewhere for reference and consumed it in your custom vector2 class

Darkside






Re: XNA Framework Altering the Origin when using Xna

Joel Martinez

I'd say that if you're going to wrap Vector2, do it in a struct and not a class ... the Garbage Collector will thank you