• Our software update is now concluded. You will need to reset your password to log in. In order to do this, you will have to click "Log in" in the top right corner and then "Forgot your password?".
  • Our weekly protagonist poll is now up! Vote for your favorite Kanto protagonist in the poll by clicking here.
  • Welcome to PokéCommunity! Register now and join one of the best fan communities on the 'net to talk Pokémon and more! We are not affiliated with The Pokémon Company or Nintendo.

Open new scene in a scene?

  • 119
    Posts
    11
    Years
    hi, i was wondering how to open a scene within a scene, and when the new scene is closed return to the old scene. I am able to enter the new scene, but when i try and return to the old scene it return but is frozen.

    Help would be appreciated. Thanks
     
    Try using break...

    Maybe it will help if we knew what you were doing?
    Is it to do with the menu or PokéDex, things like that?
    Or is it a custom script that you're calling from?
     
    Try using break...

    Maybe it will help if we knew what you were doing?
    Is it to do with the menu or PokéDex, things like that?
    Or is it a custom script that you're calling from?

    its a custom script. Heres the script part where its calling the new scene highlighted in red
    Spoiler:


    and this is the script its calling
    Spoiler:


    In that second scene when the hit x i would like it to return to the original scene.
    thanks
     
    Try using:
    Code:
    scene=OptionScene.new
    screen=OptionSceneStart.new(scene)
    screen.pbStartScreen
    And add this to you script, at the very bottom:
    Code:
    class OptionSceneStart
      def initialize(scene)
        @scene=scene
      end
    
      def pbStartScreen
        @scene.openscene
      end
    end
     
    Try using:
    Code:
    scene=OptionScene.new
    screen=OptionSceneStart.new(scene)
    screen.pbStartScreen
    And add this to you script, at the very bottom:
    Code:
    class OptionSceneStart
      def initialize(scene)
        @scene=scene
      end
    
      def pbStartScreen
        @scene.openscene
      end
    end

    hmm. that didnt seem to fix it, im not sure if its updating properly because it dos return to the first scene but doesnt allow for me to use my arrow keys.
    here is a video example

    https://www.youtube.com/watch?v=HP-KwY6nnuc&feature=youtu.be
     
    A scene is nothing more than a glorified class, containing its own separate update loops. Personally I'm not a fan of how Essentials handles scenes (by dividing them in classes and then with that awkward call). You could easily set something up along the lines of
    Code:
    class Scene
      
      def initialize
        # Initialize your main elements of the scene here
        self.main # call to the main loop of the scene
      end
      
      def openscene
        # Do whatever you want here when the scene first opens
      end
      
      def endscene
        # Dispose all your sprites here and such
      end
      
      def main
        # If you want to do something specific for when your scene opens
        self.openscene
        # The main loop of the scene, which is the main body of the update structure
        # This loop will take over the other loop you had running
        loop do
          # Do all your graphics, input and various updates here
          break if #(whatever parameter you do for breaking the scene)
        end
        # After the loop breaks (i.e. scene is closed) trigger all the closing
        # methods and/or disposals
        self.endscene 
      end
        
    end
    And the scene in question would be loaded from within another scene by a simple Scene.new. I've annotated pretty much everything in the class itself. But what it does is
    call scene > initialize content > run the main loop > (after loop breaks) end scene​
    And as soon as the main loop of the scene is broken, it will close itself and return to the state of the previous scene it was called from.
     
    A scene is nothing more than a glorified class, containing its own separate update loops. Personally I'm not a fan of how Essentials handles scenes (by dividing them in classes and then with that awkward call). You could easily set something up along the lines of
    Code:
    class Scene
      
      def initialize
        # Initialize your main elements of the scene here
        self.main # call to the main loop of the scene
      end
      
      def openscene
        # Do whatever you want here when the scene first opens
      end
      
      def endscene
        # Dispose all your sprites here and such
      end
      
      def main
        # If you want to do something specific for when your scene opens
        self.openscene
        # The main loop of the scene, which is the main body of the update structure
        # This loop will take over the other loop you had running
        loop do
          # Do all your graphics, input and various updates here
          break if #(whatever parameter you do for breaking the scene)
        end
        # After the loop breaks (i.e. scene is closed) trigger all the closing
        # methods and/or disposals
        self.endscene 
      end
        
    end
    And the scene in question would be loaded from within another scene by a simple Scene.new. I've annotated pretty much everything in the class itself. But what it does is
    call scene > initialize content > run the main loop > (after loop breaks) end scene​
    And as soon as the main loop of the scene is broken, it will close itself and return to the state of the previous scene it was called from.

    Thanks for the help, I was able to get it working :)
     
    Back
    Top