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.

Add Image to window

I've got a window displaying text as I want, but I'm stuck when trying to add an image from the pictures folder.
Can anyone point me in the correct direction

Code:
class Window_Realms < Window_Base

  #--------------------------------------------------------------------------

  # * Object Initialization

  #--------------------------------------------------------------------------

  def initialize

    @index = []

    super(0, 0, 440, 480)

    self.contents = Bitmap.new(width - 32, height - 32)

    refresh

  end

  

  def setIndex(i)

    @index = i

    refresh

  end

  

  def refresh

      self.contents.dispose

      self.contents = Bitmap.new(width - 32, height - 32)

      

      if @index.size == 7

        name = ($game_variables[@index[5]] > 0) ? @index[0] : "???"

        desc = ($game_variables[@index[5]] > 0) ? @index[1] : "???"

        complete = ($game_variables[@index[5]] == 0) ? "???" : ($game_variables[@index[5]] == 2) ? "Complete" : "Incomplete"

        

        self.contents.draw_text(10, 10, 450, 32, "Name: #{name} - #{complete}")

        self.contents.draw_text(10, 40, 450, 32, "Description:")

        self.contents.draw_text(10, 70, 450, 32, desc)

      end

  end

end
 
Solution
You want blit - i,e.


bitmap = Bitmap.new("Graphics/Pictures/picture.png)
self.contents.blt(x, y, bitmap, Rect.new(0, 0, bitmap.width, bitmap.height))




The rect part defines the part of the image you want to show, so in this case just the whole pic, useful for spritesheets.

Been a while so am a bit rusty!
You want blit - i,e.


bitmap = Bitmap.new("Graphics/Pictures/picture.png)
self.contents.blt(x, y, bitmap, Rect.new(0, 0, bitmap.width, bitmap.height))




The rect part defines the part of the image you want to show, so in this case just the whole pic, useful for spritesheets.

Been a while so am a bit rusty!
 
Solution

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