Jump to content
New account registrations are disabed. This website is now an archive. Read more here.
  • 0
Izyees Fariz

How to close window when pressing "X" or "Esc" ?

Question

Hello, I'm new in rgss1 .
I use this script :

class Window_2 < Window_Base
  
  def initialize
    super(0, 0, 640,380)
    self.contents = Bitmap.new(width-32, height-32)
    self.contents.font.name = "Arial"  
    self.contents.font.size = 24
    
    for i in 0...$game_party.actors.size
      x = 0
      y = i * 90
      actor = $game_party.actors[i]
      self.contents.font.color = text_color(6)
      self.contents.draw_text(x, y, 200, 32, $game_party.actors[i].name)
      self.contents.font.color = text_color(4)
      self.contents.draw_text(x+500, y, 200, 32, actor.class_name)
      self.contents.font.color = text_color(2)
      self.contents.draw_text(x, y+32, 200, 32, "Level : " + actor.level.to_s)
    end
  end
end


class Window_3 < Window_Base
  
  def initialize
    super(0, 380, 640,100)
    self.contents = Bitmap.new(width-32, height-32)
    self.contents.font.name = "Arial"  
    self.contents.font.size = 24
    self.contents.draw_text(0, 450, 200, 32, "Hello")
  end
end

#==============================================================================
# * Scene_ShowWindow
#==============================================================================

class Scene_ShowWindow2
  #--------------------------------------------------------------------------
  # * Main Processing
  #--------------------------------------------------------------------------
  def main
    #call the window
    @window = Window_2.new
    @window = Window_3.new
    # Execute transition
    Graphics.transition
    # Main loop
    loop do
      # Update game screen
      Graphics.update
      # Update input information
      Input.update
      # Frame update
      update
      # Abort loop if screen is changed
      if $scene != self
        break
     end
    end
    # Prepare for transition
    Graphics.freeze
    # Dispose of windows
    @window.dispose
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    # Update windows
    @window.update
    # If B button was pressed
    if Input.trigger?(Input::B)
      # Play cancel SE
      $game_system.se_play($data_system.cancel_se)
      # Switch to Menu screen
      $scene = Scene_Map.new
      return
    end
  end
end


When i pressed "X" , it's only close the small window. The big window still in the map.

How can I make all window close when I pressing "X" ?

Thanks. :)

 

Share this post


Link to post
Share on other sites

5 answers to this question

Recommended Posts

  • 0

It only closes the small window because when you press "X", it closes "@window" but it only uses the last "@window=", so the first one will get ignored and not updated by any input.

If you make it like:

def main
    #call the window
    @window2 = Window_2.new
    @window3 = Window_3.new

You'd also need to do the same with the dispose and update.

So instead of just "@window.dispose"

you must make it 

@window1.dispose
@window2.dispose

and some with update.

 

That should help :)

Share this post


Link to post
Share on other sites
  • 0

for the "choice window," that's actually a command window, which if you take a look at the list of scripts you can find it labeled as Window_Command.

 

If you go to Scene_Menu and take a look at line 26, you should see a line that looks like this:

@command_window = Window_Command.new(160, [s1, s2, s3, s4, s5, s6])

that is where the window is being called into the scene.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...