Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Scene_DrawTextTest < Scene_Base
- TEST_TEXT = "The green area is the rect given by Bitmap#text_size." # +
- " And this is just an extra optional line that can be added to the above to demonstrate the error."
- # the green area is the rect given by Bitmap#text_size for the above string,
- # and the text is drawn to this rect
- # by definition, the text should be of approximately the same size as the rect
- # and should not shift if alignment is changed, but neither is true
- # if you make the above string really long (as in, for horizonally scrolling text)
- # the draw text will collapse over itself (uncomment the plus to see)
- ALIGN = 0 # text_size issue is really ovbious when aligned left
- # but try center with longer text, to show text drawing over itself for no reason
- # to make matters worse, it doesnt even properly center when this happens
- def start
- @sprite = Sprite_Base.new
- rect = Cache.empty_bitmap.text_size(TEST_TEXT)
- @sprite.bitmap = Bitmap.new(rect.width, rect.height)
- @sprite.bitmap.fill_rect(rect, Color.new(0, 128, 0))
- @sprite.bitmap.draw_text(rect, TEST_TEXT, ALIGN)
- center_sprite(@sprite)
- end
- def update
- super
- @sprite.update
- exit if Input.trigger?(:C)
- end
- def center_sprite(sprite)
- sprite.ox = sprite.bitmap.width / 2
- sprite.oy = sprite.bitmap.height / 2
- sprite.x = Graphics.width / 2
- sprite.y = Graphics.height / 2
- end
- def terminate
- end
- end
- module Cache
- def self.empty_bitmap
- Bitmap.new(32, 32)
- end
- end
- $scene = Scene_DrawTextTest.new
- $scene.main while $scene
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement