locked
2D camera? RRS feed

  • Question

  • I'm developing a pure 2D game in XNA. How can I rotate the camera in 2D space? Is there "camera" in 2D?
    Actually I have a pretty huge backgorund texture which I'd like to rotate. It would be better rotating a camera object than the whole texture :)

    Thanks in advance

    Wednesday, October 11, 2006 9:47 PM

Answers

  • Although I am not sure with the entire Texture2D and SpriteBatch usage along if that's what you're using, but you could just make like a topview 3D camera and disable any alteration of the Z-axis for the camera. Giving you a 3D camera which basically acts like a '2D' camera.
    Wednesday, October 11, 2006 9:52 PM
  • If you are using SpriteBatch then there is no camera that you can move to have an effect on everything you draw.

    You have 2 choices:

    1. Rotate and position everything yourself. e.g. for panning you just have to have an x and y offset that you add to the coordinates.

    2. Create your own sprite class that does everything in untransformed coodinates (sprite uses transformed screen coordinates) and then you will be able to control the camera.

    Wednesday, October 11, 2006 10:20 PM

All replies

  • Although I am not sure with the entire Texture2D and SpriteBatch usage along if that's what you're using, but you could just make like a topview 3D camera and disable any alteration of the Z-axis for the camera. Giving you a 3D camera which basically acts like a '2D' camera.
    Wednesday, October 11, 2006 9:52 PM
  • If you are using SpriteBatch then there is no camera that you can move to have an effect on everything you draw.

    You have 2 choices:

    1. Rotate and position everything yourself. e.g. for panning you just have to have an x and y offset that you add to the coordinates.

    2. Create your own sprite class that does everything in untransformed coodinates (sprite uses transformed screen coordinates) and then you will be able to control the camera.

    Wednesday, October 11, 2006 10:20 PM
  • It works fine and really fast, but there is a problem. I can't join two textures precisely because when I rotate them there is a flickering line between them. I guess learning xna 3d stuffs would be an easier way...

    Thank you guys :)

    Thursday, October 12, 2006 2:10 PM