- Joined
- May 15, 2012
- Messages
- 14,682
- Reaction score
- 3,003
- First Language
- Tagalog
- Primarily Uses
- RMVXA
though you might need to adjust x,y too if you do that... stretch_blt and blt will be easier, and it seems to be used in the defaults too...
DataManager.init$game_map.interpreter.window_on(Window_Gold, 'testing')folder = $game_message.michael_wndw_bg_ary[Window_Gold][2]name = $game_message.michael_wndw_bg_ary[Window_Gold][1]b = Cache.cache_extended(folder, name)s = Sprite.new()s.bitmap = bw = Window.new(0, 0, Graphics.width, Graphics.height)w.visible = falses.zoom_x = w.width / s.bitmap.width.to_fs.zoom_y = w.height / s.bitmap.height.to_floop do Input.update Graphics.update s.zoom_x += 0.001 if Input.repeat?(:RIGHT) s.zoom_x -= 0.001 if Input.repeat?(:LEFT) s.zoom_y += 0.001 if Input.repeat?(:UP) s.zoom_y -= 0.001 if Input.repeat?(:DOWN) p s.zoom_x, s.zoom_y if Input.trigger?(: s.dispose break endend
I didn't know that... Thanks for stopping me from continuing the inefficient research. I might be able to get that "bigger" rounding offset if I keep collecting data and find the pattern, but hey, if I could make the code more simple and less math, that would be great, too. I'll try that, I was careless by setting src_rect size to be that of the graphic size...0.74418 is correctly calculated. The issue is that you are setting src_rect to the screen's size instead of the bitmap's size. zoom considers src_rect size but it also considers the actual bitmap size. It seems there is an internal rounding error for calculating the display width and height if the src_rect happens to be anything bigger than the bitmap (a more than the actual bitmap is considered for display, but not the entire dimensions of the src_rect), resulting in the gap. If you are using a src_rect smaller than the bitmap, then you need to use the src_rect's dimensions in the zoom calculation (since that is actually what is displayed). The safest way would just be to set the src_rect's values to the bitmap's dimensions before calculating zoom, then use the src_rect's dimensions to calculate zoom.
I've learned so much by now on both ruby and RGSS. : DGlad you got it working. I would have said something sooner except I wasn't even aware that causing a src_rect bigger than the sprites bitmap would cause a rounding error in the sprite's zoom function as I've never had a legitimate reason to ever set the src_rect bigger than the bitmap's size. You never stop learning.