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]SDK Hud problem

Ok so I have this Hud script that right now I'm using just to "draw" a box.

Code:
#==============================================================================
# Sidebar_Hud
#------------------------------------------------------------------------------
# By: L0rdPh0enix
# Helped by: Khmp, Gando  
# 5/4/2008
#------------------------------------------------------------------------------
#==============================================================================
  HUD_SWITCH = 2

  class Sidebar_Hud < Window_Base
  #--------------------------------------------------------------------------
  # * Initialize             
  #--------------------------------------------------------------------------
  def initialize
    super(0, 0, 383, 32) #super(587, 93, 52, 276) 
    self.z = 8000
    self.contents = Bitmap.new(width - 32, height - 32)
    self.opacity = 200
    self.visible = false
    refresh
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
  end
  #--------------------------------------------------------------------------
  # * Update
  #--------------------------------------------------------------------------
  def update
    super
  end 
end
#==============================================================================
# ** Scene_Map
#==============================================================================
class Scene_Map

  alias sidebarhud_main main
  alias sidebarhud_update update
  def main
    @sidebarhud = Sidebar_Hud.new
    sidebarhud_main
    @sidebarhud.dispose
  end
  def update
    if $game_switches[HUD_SWITCH]
      @sidebarhud.visible = true
    else
      @sidebarhud.visible = false
    end
    @sidebarhud.update
    sidebarhud_update
  end
end

The problem is when I use this
Code:
super(587, 93, 52, 276)
It works just fine, but not where I want it.

If I use this
Code:
super(0, 0, 383, 32)
then SDK 2.4 crashes with an error from this part of the script.

Code:
  def initialize(*args)
    # Original Initialization
    sdk_bitmap_init(*args)
    # Turn Disable Dispose ON
    @disable_dispose = true
  end
end

"sdk_bitmap_init(*args)"

Any idea why it's doing this?
 
Here's the snippet of code from the SDK 2.4 from Lines 2254 to 2276.

Code:
#==============================================================================
# ** Bitmap
#==============================================================================

class Bitmap
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_accessor :disable_dispose
  #--------------------------------------------------------------------------
  # * Alias Listings
  #--------------------------------------------------------------------------
  alias_method :sdk_bitmap_init, :initialize
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize(*args)
    # Original Initialization
    sdk_bitmap_init(*args)
    # Turn Disable Dispose ON
    @disable_dispose = true
  end
end

Hope that's what you ment.
 

e

Sponsor

Mmm...you're error could be this:

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

Width and height are undefined; it'd be "self.width - 32" and "self.height - 32" or something.
 
wait so I had the values with this reversed

super(0, 0, 383, 32)

the 0,0 is the width and height and the 382, 32 is the X and Y?

it's been a bit since I worked on this script :P.

Edit:
Wow I just tested that way and it works now. I feel like a noob, thanks for the help smiling snail, the .
 
@lordphoenix
First, you should tell the error message. It has the same importance than the script line. About the syntax, it is (x, y, width, height), so 0, 0 is the x,y coordinate, and 383, 32 is the bitmap size.

@smiling snail
if you call "width" inside a class' method, and it's not a local variable, Ruby will call "self.width". it's the same as calling "sdk_bitmap_init(*args)" and not "self.sdk_bitmap_init(*args)".
 
l0rdph0enix":2u8hikr9 said:
then SDK 2.4 crashes with an error from this part of the script.

Code:
  def initialize(*args)
    # Original Initialization
    sdk_bitmap_init(*args)
    # Turn Disable Dispose ON
    @disable_dispose = true
  end
end

"sdk_bitmap_init(*args)"

I've had this problem a few times, I think it's from trying to create a bitmap with no area (0 width or height)
 

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