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.

returning the dimensions of a bitmap

I'm trying to place the Help window in the middle and bottom of the enemy battler, but I'm having some trouble finding the bottom, i.e., finding the height of the bitmap so that I can subtract half of it from Help_Window.y. This is what I've got so far:

Code:
  def update_help
    @help_window.x = self.enemy.screen_x
    @help_window.y = self.enemy.screen_y - ([b]self.enemy.battler_name.height/2[/b])
    @help_window.width = 160
    @help_window.set_enemy(self.enemy)
  end

any help on this would be appreciated.
 
battler_name is only a string with the picture name. and strings don't have height. bitmaps have heights. so we have to load the battler bitmap and then get its height.
Code:
  def update_help
    @help_window.x = self.enemy.screen_x
    [B]bitmap = RPG::Cache.battler(self.enemy.battler_name, 0)[/B]
    @help_window.y = self.enemy.screen_y - ([B]bitmap.height[/B]/2)
    @help_window.width = 160
    @help_window.set_enemy(self.enemy)
  end
 
...
I can't believe I didn't think of that.

BUT

I actually didn't need the dimensions of the battler. All I needed to do (since
Code:
@help_window = self.enemy.screen_y
displays the help window at the bottom anyway, was
Code:
@help_window.x = self.enemy.screen_x - (@help_window.width/2)
There's to four hours of sleep last night.
 

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