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.

strange draw_text issue

ok here is the code im using
[rgss] 
cx = contents.text_size($game_party.actors[@actor].name).width
p($game_party.actors[@actor].name)
self.contents.draw_text\
(4+((@index-1)*104)+((@index-1)*14), 32, cx, 32, $game_party.actors[@actor].name)
 
[/rgss]

ok the code runs fine, but the problem i get is it gives me all the right character names for the print statement, but for the draw_text statement i end up getting all actor 1 data. i have no idea how this is possible. here is screen shot of results
v434a0.jpg
 
Strange that they don't match.... would have to see the whole method, and probably the method that calls it.

Is @actor an integer, or a Game_Actor object?

does $game_party.actors[@index - 1].name) work?

or just @actor.name
 
@actor is an integer and it really is @actor-1 just i tend to get people who whine about using -1 so much so i didnt include it. here is the real code
[rgss] 
def refresh
    self.contents.clear
    self.contents = RPG::Cache.picture("MenuDefault")
    self.contents.font.color = system_color
    cx = contents.text_size("Hp").width
    self.contents.draw_text(4, 0, cx, 32, "Hp")
    self.contents.font.color = system_color #change color latter
    cx = contents.text_size($game_party.actors[@actor-1].name).width
    p($game_party.actors[@actor-1].name)
    self.contents.draw_text(4+((@index-1)*104)+((@index-1)*14), 32, cx, 32, $game_party.actors[@actor-1].name)
  end
 
[/rgss]
i have four instances of this window just so you know

@leader = window_stats.new(1,1)
@member1 = window_stats.new(2,2)
@member2 = window_stats.new(3,3)
@member3 = window_stats.new(4,4)
 
Ok, 2 problems. Since you have a separate window for each character, you don't need to offset the X location of the text. They're all 4.

Also, it looks like when you Cache the picture,
self.contents = RPG::Cache.picture("MenuDefault")
then change the bitmap in the cached image by drawing the text on it, the next time you use it it's changed. (Has the previous name on it).

Try something like....

Code:
#==============================================================================

# ** Window_Gold

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

#  This window displays amount of gold.

#==============================================================================

 

class Window_Stats < Window_Base

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

  # * Object Initialization

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

  def initialize(index, actor)

    super(0, 0, 136, 352)

    @index = index

    @actor = actor

    @bg_bitmap = RPG::Cache.picture("MenuDefault")

    self.windowskin = nil

    self.contents = Bitmap.new(104,320)

    self.x = 148+((index-1)*104)+((index-1)*14)

    self.y = 55

    refresh

  end

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

  # * Refresh

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

  def refresh

    self.contents.clear

    self.contents.blt(0,0,@bg_bitmap,Rect.new(0,0,104,320))

    self.contents.font.color = system_color

    cx = contents.text_size("Hp").width

    self.contents.draw_text(4, 0, cx, 32, "Hp")

    self.contents.font.color = system_color #change color latter

    cx = contents.text_size($game_party.actors[@actor-1].name).width

    p($game_party.actors[@actor-1].name)

### self.contents.draw_text(4+((@index-1)*104)+((@index-1)*14), 32, cx, 32, $game_party.actors[@actor-1].name)

    self.contents.draw_text(4, 32, 96, 32, $game_party.actors[@actor-1].name)

  end

end

 
 

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