Advertisement Jump to content
Sign in to follow this  

need some advice in how to implement 2d zoom

This topic is 3865 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
Sign in to follow this  

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!