Jump to content
• Advertisement

# Move sprites or move camera...

This topic is 4823 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

##### Share on other sites
Advertisement
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

##### Share on other sites
Move the camera! Take advantage of 2d-in-3d.

#### Share this 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

##### 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

##### Share on other sites

• Advertisement
• Advertisement

• ### Popular Contributors

1. 1
Rutin
47
2. 2
3. 3
4. 4
5. 5
• Advertisement

• 10
• 27
• 20
• 9
• 20
• ### Forum Statistics

• Total Topics
633405
• Total Posts
3011681
• ### Who's Online (See full list)

There are no registered users currently online

×

## Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!