Drawing contents.. again!
#3
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.

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
Up is down, left is right and sideways is straight ahead. - Cord "Circle of Iron", 1978 (written by Bruce Lee and James Coburn... really...)

[Image: QrnbKlx.jpg]
[Image: sGz1ErF.png]    [Image: liM4ikn.png]    [Image: fdzKgZA.png]    [Image: sj0H81z.png]
[Image: QL7oRau.png]    [Image: uSqjY09.png]    [Image: GAA3qE9.png]    [Image: 2Hmnx1G.png]    [Image: BwtNdKw.png%5B]
  Above are clickable links
}


Messages In This Thread
Drawing contents.. again! - by Gardesion - 04-21-2014, 02:01 AM
RE: Drawing contents.. again! - by MechanicalPen - 04-21-2014, 05:46 PM
RE: Drawing contents.. again! - by DerVVulfman - 04-21-2014, 06:46 PM
RE: Drawing contents.. again! - by Gardesion - 04-22-2014, 02:41 AM
RE: Drawing contents.. again! - by JayRay - 04-22-2014, 02:49 AM
RE: Drawing contents.. again! - by Gardesion - 04-22-2014, 02:55 AM
RE: Drawing contents.. again! - by DerVVulfman - 04-22-2014, 03:17 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
Wink Drawing contents Gardesion 3 4,956 03-17-2014, 04:53 AM
Last Post: JayRay



Users browsing this thread: 3 Guest(s)