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.

[Resolved]How do I display pictures in windows?

Status
Not open for further replies.
I know this is a pretty dumb question...Don't ask what this window's for because it's totally random. I'm just trying to learn stuff lol. Anyway, I have a PNG pic called HEART in my graphics/pictures folder and I want it to appear in this window:
Code:
class Window_3 <Window_Base
  def initialize(actor)
    super(0, 300, 200, 120)
    self.contents = Bitmap.new(width-32, height-32)
    @actor = $game_party.actors[3]
    refresh
  end
  def refresh
    self.contents.clear
    draw_actor_graphic(@actor, 20, 60)
    draw_actor_name(@actor, 80, 0)
    [B]bitmap = RPG::Cache.picture(HEART)[/B]
  end
end
I get this error:
'Script "Window_3" line 15: NameError occured.
uninitialized constant Window_3::HEART'
I'm a newbie please tell me what I did wrong.
 

Mac

Member

Thats because HEART should be in quotations like so:-

Code:
class Window_3 <Window_Base
  def initialize(actor)
    super(0, 300, 200, 120)
    self.contents = Bitmap.new(width-32, height-32)
    @actor = $game_party.actors[3]
    refresh
  end
  def refresh
    self.contents.clear
    draw_actor_graphic(@actor, 20, 60)
    draw_actor_name(@actor, 80, 0)
    bitmap = RPG::Cache.picture("HEART")
  end
end
 
That quotes will fix the error, but it will still not show the picture.
Use this:
Code:
class Window_3 <Window_Base
  def initialize(actor)
    super(0, 300, 200, 120)
    self.contents = Bitmap.new(width-32, height-32)
    @actor = $game_party.actors[3]
    refresh
  end
  def refresh
    self.contents.clear
    draw_actor_graphic(@actor, 20, 60)
    draw_actor_name(@actor, 80, 0)
    bitmap = RPG::Cache.picture("HEART")
    self.contents.blt(x, y, bitmap, Rect.new(0, 0, bitmap.width, bitmap.height))
  end
end
Change x, y for the coordinates you want.
 
This topic has been resolved. If ToriVerly or any other users have any questions or further problems regarding this topic, please create a new thread about them.

Thank you!
 
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