nor0x
nor0x

Reputation: 1213

2D XNA-Camera and fixed Background

I am currently creating a XNA-Game for Windows Phone. I have a problem concerning the 2D camera and the background.

Is it possible to move the XNA-Camera and fix the background, so that it is not moving with the camera-view? Furthermore also my pause-button and the menu-bar is moving, hopefully it's possible to fix them to the top of the screen.

UPDATE: Here is my move-Methode from the camera class:

    public void Move(Vector2 amount)
    {
        _pos += amount;
    }

Screenshot: http://www.abload.de/img/screenshotbdllj.png

As you can see on the picture the box-object is falling top-down and the background is moving up. Is there a way to keep the background static fixed?

Upvotes: 0

Views: 1126

Answers (1)

vinzenz
vinzenz

Reputation: 689

If you work in 2D-Space you'll could have something like this:

spriteBatch.Begin(SomeSortmode,nullnull,etc..., Matrix);
//drawstuff
spriteBatch.End();

If this is the case, move your rendering code into another Begin() and End()

I think of something like this:

spriteBatch.Begin(SomeSortmode,nullnull,etc..., Matrix);
//draw stuff affected by the camera
spriteBatch.End();

spriteBatch.Begin()
//draw stuff which should not be affected by the camera
spriteBatch.End();

Upvotes: 3

Related Questions