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] Can't get Window to work!

Status
Not open for further replies.
Okay... I think this is an easy thing to do, but I simply can't...

I have a problem with the command window of a scene I want to make...
it is there... but it simply doesn't work! the cursor don't move!

here's the part of the code:

here's the scene
Code:
class Scene_Build
  
  def initialize(actor)
    @actor_index = actor
  end
  
  def main
    s1 = "Aumentar HP" #8,9,10,11,12,13,17,33,38,39,40,41,42,43
    s2 = "Aumentar MP"
    s3 = "Aumentar Força"
    s4 = "Aumentar Destreza"
    s5 = "Aumentar Agilidade"
    s6 = "Aumentar Inteligência"
    @actor = $game_party.actors[@actor_index]
    # Criar a janela de Status
    @build_window = Window_BuildStatus.new(@actor)
    @build_commandwindow = Window_BuildCommand.new([s1, s2, s3, s4, s5, s6])
    @build_commandwindow.index = 0
    Graphics.transition
    loop do
      # Aqui a tela é atualizada
      Graphics.update
      # E os dados também
      Input.update
      # Então os frames são atualizados
      update
      # Abortar loop se a janela for alterada
      if $scene != self
        break
      end
    end
    Graphics.freeze
    @build_window.dispose
    @build_commandwindow.dispose
  end
  
  def update
    # Caso o botão B seja pressionado
    if Input.trigger?(Input::C)
      case @build_commandwindow.index
      when 1 #HP
        hp = @actor.maxhp
        exp = (hp**2)/100
        if @actor.exp >= exp then
          @actor.exp -= exp
          @actor.maxhp += 10
        else
          $game_system.se_play($data_system.cancel_se)
        end
      when 2 #MP
        sp = @actor.maxsp
        exp = (sp**2)/10
        if @actor.exp >= exp then
          @actor.exp -= exp
          @actor.maxsp += 5
        else
          $game_system.se_play($data_system.cancel_se)
        end
      when 3 #Str
        str = @actor.str
        exp = (str**2)/10
        if @actor.exp >= exp then
          @actor.exp -= exp
          @actor.str += 5
        else
          $game_system.se_play($data_system.cancel_se)
        end
      end
    end
    if Input.trigger?(Input::B)
      # É tocada a música SE de cancelamento
      $game_system.se_play($data_system.cancel_se)
      # Mudar para a tela do Mapa
      $scene = Scene_Menu.new(4)
      return
    end
    if Input.trigger?(Input::R)
      # Reproduzir Se de seleção
      $game_system.se_play($data_system.cursor_se)
      # Para o próximo Herói
      @actor_index += 1
      @actor_index %= $game_party.actors.size
      # Mudar para uma tela de Status diferente
      $scene = Scene_Build.new(@actor_index)
      return
    end
    if Input.trigger?(Input::L)
      # Reproduzir SE de seleção
      $game_system.se_play($data_system.cursor_se)
      # Para o Herói anterior
      @actor_index += $game_party.actors.size - 1
      @actor_index %= $game_party.actors.size
      # Mudar para uma tela de Status diferente
      $scene = Scene_Build.new(@actor_index)
      return
    end
  end
end

and the window_buildcommand:
Code:
class Window_BuildCommand < Window_Selectable
  
  def initialize(commands)
    super(440, 0, 200, 480)
    @column_max = 1
    @commands = commands
    self.contents = Bitmap.new(width - 32, height - 32)
    refresh
    self.index = 0
  end

  def refresh
    self.contents.clear
    for i in 0...6
      draw_item(i, normal_color)
    end
  end
  
  def draw_item(index, color)
    self.contents.font.color = color
    rect = Rect.new(4, 32 * index, self.contents.width - 8, 32)
    self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
    self.contents.draw_text(rect, @commands[index])
  end
end

don't mind the "Window_BuildStatus" Reference, 'nor the incoplete command case... I just want Window_BuildCommand to work... thanks!
 
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