I develop a 2D match3 game in XNA. The core logic and animations are done. I use RenderTarget2D to draw the entire board. The board has 8 rows and 8 columns with 64×64 textures (the tiles), which could be clicked and moved. To capture the mouse intersection, I use SourceRectangles for each tile. Of course the SourceRectangles have same size as textures – 64×64.
I would like to scale down the entire board, using the RenderTarget2D, to support different monitor resolutions and aspects. First I draw all tiles in the RenderTarget2D. Then I scale down the RenderTarget2D with a float coefficient. Finally I draw the RenderTarget2D on the screen. As a result the entire board is scaled down properly (all textures are scaled down from 64×64 to 50×50 for example), but the SourceRectagles are not scaled, they remain 64×64 and mouse intersections are not captured for the proper tiles.
Why scaling the RenderTarget2D doesn’t handle this? How I can solve this problem?
You should approach this problem differently. Your source rectangles for textures are just that — don’t try to use them as button rectangles, or you will get in trouble like this.
Instead, use a different
Rectangle hitboxRectangle, which will be the same size as your source rectangle initially, but will scale with your game window, and check intersections against it.