Sign in to follow this  

Move sprites or move camera...

This topic is 4484 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi all, I have lots of 2d sprites on screen (tiles) and I am currently moving the character by moving all of the tiles. Would it be more efficient to move the camera instead? I was just curious as I stumbled upon that implementation on a website, and the author claimed it to be faster. Any thoughts on the matter?

Share this post


Link to post
Share on other sites
I would imagine that moving the camera would be less CPU intensive. By moving every tile you have to apply calculations and matrix transforms, etc to every tile being moved. Alternatively, if you just move the camera you only need to do one set of matrix transforms each frame.

Share this post


Link to post
Share on other sites
Thanks for your replys!

Would I still be able to use coordinates if I move the camera?

As of now I am positioning the camera and setting it so the upper left is 0, 0 and all the coordinates are positive.

Thanks,

Share this post


Link to post
Share on other sites
BTW, this is how I am setting up my camera...

// get camera vectors
float width = (float)_targetControl.ClientSize.Width;
float height = (float)_targetControl.ClientSize.Height;
float centerX = width / 2.0f;
float centerY = height / 2.0f;
Vector3 cameraPosition = new Vector3(centerX, centerY, -5.0f);
Vector3 cameraTarget = new Vector3(centerX, centerY, 0.0f);

// create our transforms
newDevice.Transform.View = Matrix.LookAtLH(cameraPosition, cameraTarget, new Vector3(0.0f, 1.0f, 0.0f));

newDevice.Transform.Projection = Matrix.OrthoLH(width, height, 1.0f, 10.0f);

Share this post


Link to post
Share on other sites

This topic is 4484 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this