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.

Calling saved scene problem........

Status
Not open for further replies.
First, read this: http://www.rmxp.org/forums/showpost.php?p=211233&postcount=177

I could solve 'calling saved scene problem with SDK2', but there's new problem.

Example code:
Code:
class Scene_Load < Scene_File
  #--------------------------------------------------------------------------
  # * Alias Listings
  #--------------------------------------------------------------------------
  alias load_initialize initialize
  alias load_on_cancel on_cancel  
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize    
    @scene = $scene.class
    load_initialize
  end
  #--------------------------------------------------------------------------
  # * Cancel Processing
  #--------------------------------------------------------------------------
  def on_cancel
    load_on_cancel
    if @scene.is_a?(Scene_Menu)
      $scene = Scene_Menu.new(7)
    else
      $scene = @scene.new
    end
  end
end
I'm using a menu script that have 'Load' command, and what I want is: select 'Load', and when cancelling load, cursor is placed on 'Load' command. However, it doesn't work on above code.

Code:
  def on_cancel
    load_on_cancel
    if @scene.is_a?(Scene_Menu) #checking current scene is ignored
      $scene = Scene_Menu.new(7) #therefore, it doesn't work
    else
      $scene = @scene.new #it works
    end
  end

If I changed above code like this, it worked like:
Code:
  def on_cancel
    load_on_cancel
    if @scene.is_a?(Scene_Menu.class) #it seems work
      $scene = Scene_Menu.new(7) #it works
    else #I think it's ignored
      $scene = @scene.new #it doesn't work, so when cancelling load, it calls Scene_Menu
    end
  end

How can I solve this? I mean, is there any way to make [email='@scene.is]'@scene.is[/email]_a?(Scene class)' work on above code?
 
Your aren't saying an object, you are saving a symbol when you use the return scene thingy. Have your code like so:

Code:
class Scene_Load < Scene_File
  #--------------------------------------------------------------------------
  # * Alias Listings
  #--------------------------------------------------------------------------
  alias_method :load_initialize, :initialize
  alias_method :load_on_cancel, :on_cancel  
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize    
    @scene = $scene.class
    load_initialize
  end
  #--------------------------------------------------------------------------
  # * Cancel Processing
  #--------------------------------------------------------------------------
  def on_cancel
    load_on_cancel
    if @scene == Scene_Menu
      $scene = Scene_Menu.new(7)
    else
      $scene = @scene.new
    end
  end
end

That should do the trick.
 
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