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.

Problem with disappearing pictures in battle

Okay, I've got this in the Window_Battlestatus class in XP:

Code:
  def refresh
    self.contents.clear
    @item_max = $game_party.actors.size
    for i in 0...$game_party.actors.size
      actor = $game_party.actors
      actor_x = i * 160 + 4
      draw_actor_name(actor, actor_x, 0)
      draw_actor_hp(actor, actor_x, 32, 120)
      draw_actor_sp(actor, actor_x, 64, 120)

      @supermetr= Sprite.new
      @supermetr.bitmap = RPG::Cache.picture('0.png')
      @supermetr.x = actor_x
      @supermetr.y=  60

      if @level_up_flags
        self.contents.font.color = normal_color
        self.contents.draw_text(actor_x, 96, 120, 32, "LEVEL UP!")
      else
        draw_actor_state(actor, actor_x, 96)
      end
    end
  end

Which then draws 0.png on the screen fine for each actor- but then after around 6 or 7 seconds, all but the rightmost one disappears- no matter how many actors there are in the party (i.e. if there's 4 the first 3 will disappear, while if there's only one it won't disappear etc). I tried searching for the problem, and a topic suggested to use global variables- which I tried and didn't change anything. What am I doing wrong?

Sorry in advance if it's a stupid question.
 

khmp

Sponsor

No it's not a stupid question. But I'm still going to insult you a bit so hang with me. Every time the window refreshes you create a new sprite? And you create it however many times that there are actors in your party? No no no... Did I mention no? Alright what in my thinking, is the code doing. First draw to the window. Create a sprite object save it to an instance variable. Then give the sprite an image to display. Now start to draw the next actor's information create a new sprite object and save it to the same instance variable. Load the same image move the sprite. Add and repeat. It probably shows properly if there's only one actor. Depending upon how often the window is refreshing.

Ok so what are you trying to do? Are you attempting to place a sprite at the position of every actor in the party. I would recommend placing this functionality within another class entirely. Or... are you trying to just add the meter thing within the window?
 
Add the meter for each actor- not in the window, though (at the top of the screen, right below where the fight/escape thingy appears).

God I'm thick- I just noticed what you meant, only one obect for the 4 of them. Sorry to bother you.
 

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