Jump to content
  • Advertisement
Sign in to follow this  
AvengerDr

2D Zooming and Scrolling

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

Hello there! I'm looking for advices on how to implement 2d zooming and scrolling, like it was done in Master of Orion 3. Basically I (will) have a background texture will be the starfield. On top of these textures I have several sun icons. I'm thinking of implementing this via sprite objects. Since the galaxy could be very big and it would become too crowded if it were to be shown in a single screen, I need some zooming. But since I've never done something like that in 2D I'm looking for advices. What is the best practice for zooming and scrolling? For zooming I thought that I could just make the sun icons bigger/smaller depending on the zoom factor. While for scrolling... well obviously I'll need to change the screen coordinates of those icons. But I was wondering if there was a better way! Thanks in advance.

Share this post


Link to post
Share on other sites
Advertisement
If I'm getting what you're saying right...

why not make a big background sprite (check for bounds on this) and place the other sprites on top of it? Then, code the camera so as only to render sprites whose location is within the camera's point of view, and implement code to move the camera instead. That way, you don't actually have to code for the possibility of moving all the sprites around themselves - you just call a camera update to get the pov you need to render.

Share this post


Link to post
Share on other sites
I'm using DirectX's sprite class. One its methods is Draw which accepts several parameters, one of these is a vector3. If I want to draw something at x,y , where x and y are screen coordinates I pass it a (x,y, 0) vector.

This makes all sprites be overlayed on the 3d scene and when I move the camera they stay on top (like a HUD). If I change the z-coordinate they disappear.

What do I have to do in order to make them be affected by the camera?

Share this post


Link to post
Share on other sites
(bump)
So is anyone able to explain me the correct usage of the method "draw" of Managed DirectX? In particular, how can I use the Vector3 parameter to make a sprite appear further away from the camera and not superimposed on the 3d scene?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

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!