Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Picture on a window

Status
Not open for further replies.
Hi!
Could anyone please tell me how I could show a picture in a window if I create a new window class that inherits from Window_Base? Is it possible? Or the new window should inherit the method from another type of window class?
Thanks for any advice that may let me solve this issue!
 
Code:
class Window_Yours < Window_Base
  def initialize
    super(x, y, width, height)
    self.contents = Bitmap.new(width - 32, height - 32
    refresh
  end
  def refresh
    self.contents.clear
    bitmap = RPG::Cache.picture(filename)
    self.contents.blt(x, y, bitmap, bitmap.rect)
  end
end

The important part is in the refresh method.

We use the Bitmap@blt method. Here's how it works:

Code:
your_bitmap.blt(x, y, bitmap, src_rect)

X and Y are the position on the bitmap of your picture. Bitmap is your picture. src_rect is the area on the picture you are taking it from. If you just want the whole picture, use bitmap.rect.
 
do you mean I should enter something like this?
Code:
def refresh
    self. contents.clear
    bitmap = RPG::Cache.picture('001-AFlag01')
    x = 512
    y = 0
    opacity = 160
    self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 192, 128), opacity)
end

What if I create a hash like this?

FLAG = {
            Empire => '001-AFLag01'
            Kingdom => '001-AFLag02'
            Republic => '001-AFLag03'
            Tyranny => '001-AFLag04'
]

I always get an error message telling me it can't convert a Hash into a String. What should I do then?
 
Status
Not open for further replies.

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top