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] Image not displaying?

Status
Not open for further replies.
I'm trying to make my window have an image instead of the windowskin, but the image doesn't want to display. This is my script:

Code:
class Window_Itachi_One < Window_Base
  
  def initialize
    super(0, 300, 70, 70)
    self.contents = Bitmap.new(width-32, height-32)
    self.contents.font.name = 'Arial'
    self.contents.font.size = 24
    self.contents.font.color = text_color(2)
    @var = nil
    refresh
  end

  def to_s
    $game_variables[15].to_s
  end

  def refresh
    self.contents.clear
    @bitmap = RPG::Cache.picture("HUD_Infection")
    self.contents.blt(width/3, height/3, @bitmap, Rect.new(0, 0, @bitmap.width, @bitmap.height), 160)
    self.contents.draw_text(0, 0, 100, 32, to_s + "%")
  end

  def update
    return if @var == $game_variables[15]
    @var = $game_variables[15]
    refresh
  end
end

class Scene_Map
    
  alias_method :old_main, :main
  alias_method :old_update, :update
  
  def main
    @window = Window_Itachi_One.new
    old_main
    @window.dispose
  end

  def update
    @window.update
    old_update
  end
end
How do I fix this?

Thanks.
 

khmp

Sponsor

Your picture was drawing. It was just out of sight. Before you change anything you can enlarge the size of your window to see your image.

The line:

Code:
self.contents.blt(width/3, height/3, @bitmap, Rect.new(0, 0, @bitmap.width, @bitmap.height), 160)

should be changed to:

Code:
self.contents.blt(0, 0, @bitmap, Rect.new(0, 0, @bitmap.width, @bitmap.height), 160)

But the picture will still draw 16 pixels right and 16 pixels down from the top-left corner of the window. What you might want to do instead is create a custom window skin for your window and just alter the construction code to use it. If you have any other questions just ask.

http://i229.photobucket.com/albums/ee31 ... i62fix.png[/IMG]

Good luck with it Itachi62! :thumb:
 

khmp

Sponsor

Well what you need doesn't seem particularly difficult to create. I mean you only need the left section of a windowskin all the rest is unnecessary. Perhaps you should give the graphic request section a chance.
 
Alright, I think I'll try to edit the RTP one, thanks.
But, I have a newb question. How do I change the windowskin so it just affects that window?

Edit: Figured it out by myself. ;)
I changed the RPG::Cache.picture("blah") part to:
Code:
RPG::Cache.windowskin("windowskin.png")
Resolved!
 
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