Jump to content
  • Advertisement
Sign in to follow this  
EvilNando

need some advice in how to implement 2d zoom

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

adding a zoom to my camera system was an afterthought, as a consequence Im finding some troubles on how to do this. let me explain myself a little bit further I have a very simple 2d camera going on for my program, where: - the camera has an x,y value, when moving the camera those values get modified directly. - every render call goes like this sprite_batch.Draw(texture, src_rect, Camera.Transform(dest_rect), my_color); as you can guess the Camera Transform just takes a data type (point, vector, rectangle) and add the inverse of its current x,y values; In this case protected Rectangle Transform(Rectangle Value) { return new Rectangle( Value.X + Camera.X * -1, Value.Y + Camera.Y * -1, Value.Width, Value.Height ); } Now the problem of having a zoom feature , as I have discovered , is that I not only need to know what is the zoom factor, but I also need to know how much the tiles displace. In the end Ive learned that this is not as trivial as using the spritebatch's draw overload that receives a scale factor, I also need to offset the tiles, and by doing that I think that I will need to transform my destination rectangle's width and height accordingly. any guidance about a possible course of action will be greatly appreciatted and I dont want to think about how Im supposed to do with my input handling routines once I have my zoom features in place :( Regards!

Share this post


Link to post
Share on other sites
Advertisement
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!