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.

Scene...

Jason

Awesome Bro

Script Request Template
This is a request for a new script, an edit or debug of an existing script.

Script Title:
Scene_Blahblahblah
RMXP or RMVX:
RMXP Ofcourse !
Detailed Description:
Well basically, I've made my own window, let's pretend it's named Window_JBrist, and basically, I've been trying to make a scene for this window, so it can be called from the menu. All the scene needs to contain is this one window, so it will be relatively small. The problem is, that I can't for the life of me make scenes, lol, every time I do, I get the update or dispose wrong, and the game hangs, which obviously isn't what I want, lol.

So what I'm asking, is that someone could create a scene using Window_JBrist as the object, with the co-ordinates of the window as 0,0. And if it's possible, could you please comment each area of it, so I can use it as reference in the future (And hopefully won't have to rely on other people for things such as this, lol...)

Cheers.
 
hey heres a quick one :P

Class Your_Scene

def main
#main content here
end

end

thats a basic scene no update xD

If you wanna know how to work scenes fully I would advise taking a look at Scene_End its pretty basic and can teach you a lot =)
 

Jason

Awesome Bro

Yeah but whenever I try that, and add the update and dispose methods, the script just hangs, which isn't what I want, lol.

But I guess I'll take a look at Scene_End, although I don't get the graphics transitions etc. o.O
 
Here's a basic scene for you, B button will cancel out to Scene_Map and C button doesn't do anything but its there as a starter incase you wanna do something with it, if not just delete the Input::C statement.

Assuming you've made the Window_JBrist class, its x, y, width and height should already be defined when you call the super(x, y, width, height) within the Window's initialize method, you can set the starting visible/active and all that too within the window's initialize method, just to keep the main opening of the scene clean and down to the point.

Code:
#===============================================================================

# ** Scene_JBrist

#===============================================================================

 

class Scene_JBrist

  #-----------------------------------------------------------------------------

  # * Main

  #-----------------------------------------------------------------------------

  def main

    # Create windows

    @window_jbrist = Window_JBrist.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_jbrist.dispose

  end

  #-----------------------------------------------------------------------------

  # * Update

  #-----------------------------------------------------------------------------

  def update

    # Update Windows

    @window_jbrist.update

    # If B button is triggered...

    if Input.trigger?(Input::B)

      # Play Cancel SE

      $game_system.se_play($data_system.cancel_se)

      # Cancel out to Scene_Map

      $scene = Scene_Map.new

    end

    # If C button is triggered...

    if Input.trigger?(Input::C)

      # Play Decision SE

      $game_system.se_play($data_system.decision_se)

      # Do something...

    end

  end

end

With standard scenes, the main loop is always going to be the same shit from scene to shining scene, just copy the following lines and put them in the middle of your def main statement. The only thing that might be different is sometimes $game_system.update is called to update the timer, other than that you won't ever need to modify the main loop unless you're trying to do something different with it so you can just copy and paste it.

Code:
    # Execute transition

    Graphics.transition

    # Main loop

    loop do

      # Update game screen

      Graphics.update

      # Update input information

      Input.update

      # Update $game_system

      # NOTE : This is only used primarily in Scene_Battle and Scene_Map

      #      to update the Timer, thats why its commented out...

      #$game_system.update

      # Frame update

      update

      # Abort loop if screen is changed

      if $scene != self

        break

      end

    end

    # Prepare for transition

    Graphics.freeze

Everything BEFORE the main loop is the opening of the scene, like when you create your windows and sprites and stuff...

Everything AFTER the main loop is the closing of the scene, where anything that responds to dispose should be disposed.

The Graphics.update is important in the main loop because, without it, the game will call a Hangup because Graphics module hasn't been updating (I don't think VX will call a Hangup, only XP does.) Also, if Graphics.update isn't called but everything is else is updating (windows being moved and such) your screen won't change but everything is still going on in your game you just can't see it lol

The Input.update should be pretty explanitory, without it then no response will come from calls like Input.trigger?(Input::C) and you won't be able to move the cursor in menus and such if it isn't called.

Oh yeah, you said you have trouble with Graphics.transition sometimes... well basically this is what it does.

Graphics.freeze : This is called when you exit a scene, it freezes everything going on. This method is called after the main loop has been broken.

Graphics.transition : This is called when you enter a scene, its the 'transition' between Scene_This and Scene_That, and it unfreezes your graphics. This method is called before the main loop starts in a scene.

So basically, create your windows first then Graphics.transition at the start of your scene, Graphics.freeze then dispose of all your windows at the end of your scene. Also you can use Graphics.transition to actually use a Transition graphic between the scenes, please look this method up in your help file and it'll tell you how to use it, its similiar to events.

Hope this helps you understand basic scene structure a little better, good luck jbrist! :thumb:
 

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