04-21-2014, 06:46 PM
Perhaps, you may wish to have this minor script-ette? Pardon possible syntax errors... I'm writing it from work, so I am actually unsure about the Icon Cache statement. *sigh*
This script add-on should allow you to draw an icon within a centered area, the icon's own width and height adjusting placement as it loads. As I put it within the Window_Base class, it should be accessible from virtually any window scripts that has it as a parent class (most all are).
AND... you don't have a size limit for your icons. Could be used as a basis for other pictures too. Also, if no filename is present... it won't blit.
This script add-on should allow you to draw an icon within a centered area, the icon's own width and height adjusting placement as it loads. As I put it within the Window_Base class, it should be accessible from virtually any window scripts that has it as a parent class (most all are).
AND... you don't have a size limit for your icons. Could be used as a basis for other pictures too. Also, if no filename is present... it won't blit.
Code:
class Window_Base
#------------------------------------------------------------------
# * Draw centered icon in place
# x : x-location (assuming center coordinates)
# y : y-location (assuming center coordinates)
# filename : icon filename
#------------------------------------------------------------------
def centered_icon(x, y, filename=nil)
# exit out if no file exists or is empty string
return if filename.nil?
return if filename = ""
# Acquire the bitmap
bitmap = RPG::Cache.icons(iconfile)
# Adjust target coords based on bitmap size (half each)
dest_x = x - (bitmap.width/2).to_i
dest_y = y - (bitmap.height/2).to_i
# create destination rectangle based on full bitmap size
dest_rect = Rect.new(0, 0, bitmap.width, bitmap.height)
# Blit image into centered position
self.contents.blt(dest_x, dest_y, bitmap, dest_rect)
end
end
![[Image: QrnbKlx.jpg]](https://i.imgur.com/QrnbKlx.jpg)
![[Image: sGz1ErF.png]](https://i.imgur.com/sGz1ErF.png)
![[Image: liM4ikn.png]](https://i.imgur.com/liM4ikn.png)
![[Image: fdzKgZA.png]](https://i.imgur.com/fdzKgZA.png)
![[Image: sj0H81z.png]](https://i.imgur.com/sj0H81z.png)
![[Image: QL7oRau.png]](https://i.imgur.com/QL7oRau.png)
![[Image: uSqjY09.png]](https://i.imgur.com/uSqjY09.png)
![[Image: GAA3qE9.png]](https://i.imgur.com/GAA3qE9.png)
![[Image: 2Hmnx1G.png]](https://i.imgur.com/2Hmnx1G.png)
![[Image: BwtNdKw.png%5B]](https://i.imgur.com/BwtNdKw.png%5B)