Skip to content

Instantly share code, notes, and snippets.

@matula
Created April 3, 2025 19:39
Show Gist options
  • Save matula/c3d698ae2c9a559d581adfc8b63df791 to your computer and use it in GitHub Desktop.
Save matula/c3d698ae2c9a559d581adfc8b63df791 to your computer and use it in GitHub Desktop.
RPG Maker MV documentation for "rpg_scenes.js"

RPG Maker MV Scene Script Documentation (rpg_scenes.js v1.6.2)

This document provides an overview of the Scene classes defined in the rpg_scenes.js file for RPG Maker MV. Scenes manage the different screens and states of the game, such as the title screen, map, menus, and battles.

Scene_Base

The superclass for all scenes in the game. It provides fundamental functionalities like managing fade-in/out, window layers, and the scene lifecycle.

Properties:

  • _active: Boolean indicating if the scene is active.
  • _fadeSign: Direction of the fade (1 for fade-in, -1 for fade-out).
  • _fadeDuration: Remaining duration of the current fade effect.
  • _fadeSprite: The ScreenSprite used for fading.
  • _imageReservationId: ID used for reserving images related to this scene.
  • _windowLayer: A WindowLayer instance to hold the scene's windows.

Methods:

  • initialize(): Constructor.
  • create(): Called when the scene is created. Meant to be overridden by subclasses to set up scene elements.
  • isActive(): Returns true if the scene is active.
  • isReady(): Checks if the scene is ready to start (typically checks if required images are loaded).
  • start(): Called when the scene becomes active.
  • update(): Updates the scene state each frame (updates fade, children).
  • stop(): Called when the scene stops being active.
  • isBusy(): Returns true if the scene is busy (e.g., during a fade).
  • terminate(): Called just before switching to another scene. Meant to be overridden for cleanup.
  • createWindowLayer(): Creates the _windowLayer.
  • addWindow(window): Adds a window to the _windowLayer.
  • attachReservation(): Attaches the scene's image reservation ID to the ImageManager.
  • detachReservation(): Releases the scene's image reservation.
  • startFadeIn(duration, white): Starts a fade-in effect.
  • startFadeOut(duration, white): Starts a fade-out effect.
  • createFadeSprite(white): Creates the sprite used for fading.
  • updateFade(): Updates the fade effect animation.
  • updateChildren(): Updates all child display objects.
  • popScene(): Switches back to the previous scene on the stack.
  • checkGameover(): Checks if the party is all dead and goes to the game over scene if so.
  • fadeOutAll(): Fades out screen and audio.
  • fadeSpeed(): Returns the default fade speed (24 frames).
  • slowFadeSpeed(): Returns a slower fade speed (48 frames).

Scene_Boot

The first scene that runs when the game starts. It handles initialization tasks.

Methods:

  • initialize(): Constructor.
  • create(): Loads the database, config, and system window image.
  • loadSystemWindowImage(): Reserves the 'Window' system image.
  • loadSystemImages(): (Static) Reserves various essential system images.
  • isReady(): Checks if the database is loaded and the game font is ready.
  • isGameFontLoaded(): Checks if the 'GameFont' has loaded, with a timeout.
  • start(): Preloads sounds, sets up the initial game state (new game, battle test, or event test), and transitions to the appropriate starting scene (Title, Battle, or Map).
  • updateDocumentTitle(): Sets the browser/window title.
  • checkPlayerLocation(): Throws an error if the player's starting position is not set.

Scene_Title

The scene for the game's title screen.

Methods:

  • initialize(): Constructor.
  • create(): Creates the background, foreground (title text), and command window.
  • start(): Plays title music and starts the fade-in.
  • update(): Updates the scene; opens the command window if not busy.
  • isBusy(): Checks if the command window is closing or the scene is fading.
  • terminate(): Snaps the current screen for use as a background in menus.
  • createBackground(): Creates the title screen background sprites (_backSprite1, _backSprite2).
  • createForeground(): Creates the sprite for drawing the game title (_gameTitleSprite).
  • drawGameTitle(): Draws the game title text onto the _gameTitleSprite.
  • centerSprite(sprite): Centers a sprite on the screen.
  • createCommandWindow(): Creates the Window_TitleCommand.
  • commandNewGame(): Handler for the 'New Game' command.
  • commandContinue(): Handler for the 'Continue' command.
  • commandOptions(): Handler for the 'Options' command.
  • playTitleMusic(): Plays the title screen BGM.

Scene_Map

The main scene where the player explores the map.

Methods:

  • initialize(): Constructor.
  • create(): Starts loading the map data based on whether it's a transfer or initial load.
  • isReady(): Checks if the map data has loaded and the base scene is ready.
  • onMapLoaded(): Called when map data finishes loading; performs transfer and creates display objects.
  • start(): Starts the scene, handles fade-in based on the previous scene, and starts map BGM/BGS.
  • update(): Main update loop for the map scene.
  • updateMainMultiply(): Calls updateMain potentially twice if fast-forwarding.
  • updateMain(): Updates map, player, timer, and screen.
  • isFastForward(): Checks if the game should be fast-forwarding (event running + OK/Touch hold).
  • stop(): Handles actions before leaving the map scene (fade-out, stopping player, launching battle).
  • isBusy(): Checks if the message window, wait count, or encounter effect is active.
  • terminate(): Cleans up map-specific resources and display objects.
  • needsFadeIn(): Determines if a fade-in is needed (coming from Battle or Load).
  • needsSlowFadeOut(): Determines if a slow fade-out is needed (going to Title or Gameover).
  • updateWaitCount(): Decrements the wait counter.
  • updateDestination(): Handles touch input for player movement destination.
  • isMapTouchOk(): Checks if touch input for map movement is allowed.
  • processMapTouch(): Processes touch input coordinates to set the player's destination.
  • isSceneChangeOk(): Checks if it's okay to transition to another scene.
  • updateScene(): Checks for game over, transfers, encounters, menu calls, or debug calls.
  • createDisplayObjects(): Creates the spriteset, map name window, window layer, and all windows.
  • createSpriteset(): Creates the Spriteset_Map.
  • createAllWindows(): Creates message and scroll text windows.
  • createMapNameWindow(): Creates the Window_MapName.
  • createMessageWindow(): Creates the Window_Message and its sub-windows.
  • createScrollTextWindow(): Creates the Window_ScrollText.
  • updateTransferPlayer(): Handles player transfer logic.
  • updateEncounter(): Handles random encounter logic.
  • updateCallMenu(): Checks for and handles menu activation input.
  • isMenuEnabled(): Checks if the menu can be opened.
  • isMenuCalled(): Checks if the menu input (Menu button or Cancel touch) occurred.
  • callMenu(): Transitions to the menu scene.
  • updateCallDebug(): Checks for and handles debug screen activation input.
  • isDebugCalled(): Checks if the debug input occurred during playtest.
  • fadeInForTransfer(): Performs fade-in specific to player transfers.
  • fadeOutForTransfer(): Performs fade-out specific to player transfers.
  • launchBattle(): Initiates the transition to the battle scene.
  • stopAudioOnBattleStart(): Stops map music before battle.
  • startEncounterEffect(): Starts the screen zoom/flash effect for battles.
  • updateEncounterEffect(): Updates the battle encounter zoom/flash effect.
  • snapForBattleBackground(): Takes a snapshot of the map for the battle background.
  • startFlashForEncounter(duration): Starts a screen flash during the encounter effect.
  • encounterEffectSpeed(): Returns the duration of the encounter effect (60 frames).

Scene_MenuBase

The superclass for all menu scenes (Item, Skill, Equip, Status, Options, Save, Load, GameEnd).

Methods:

  • initialize(): Constructor.
  • create(): Creates background, updates actor reference, creates window layer.
  • actor(): Returns the currently selected menu actor (_actor).
  • updateActor(): Updates _actor based on $gameParty.menuActor().
  • createBackground(): Creates the background sprite using the snapped image from SceneManager.
  • setBackgroundOpacity(opacity): Sets the opacity of the background sprite.
  • createHelpWindow(): Creates the Window_Help (intended to be called by subclasses).
  • nextActor(): Switches to the next party member.
  • previousActor(): Switches to the previous party member.
  • onActorChange(): Called when the actor changes (intended to be overridden).

Scene_Menu

The main menu scene.

Methods:

  • initialize(): Constructor.
  • create(): Creates command, gold, and status windows.
  • start(): Refreshes the status window.
  • createCommandWindow(): Creates the Window_MenuCommand.
  • createGoldWindow(): Creates the Window_Gold.
  • createStatusWindow(): Creates the Window_MenuStatus.
  • commandItem(): Handler for the 'Item' command.
  • commandPersonal(): Handler for skill, equip, status commands (activates status window for actor selection).
  • commandFormation(): Handler for the 'Formation' command.
  • commandOptions(): Handler for the 'Options' command.
  • commandSave(): Handler for the 'Save' command.
  • commandGameEnd(): Handler for the 'Game End' command.
  • onPersonalOk(): Handler when an actor is selected for skill/equip/status.
  • onPersonalCancel(): Handler when actor selection is cancelled.
  • onFormationOk(): Handler when an actor is selected in formation mode (initiates or completes swap).
  • onFormationCancel(): Handler when formation selection/swap is cancelled.

Scene_ItemBase

The superclass for Scene_Item and Scene_Skill.

Methods:

  • initialize(): Constructor.
  • create(): Base creation logic.
  • createActorWindow(): Creates the Window_MenuActor for selecting the target actor.
  • item(): Returns the currently selected item/skill from the _itemWindow.
  • user(): Returns the actor using the item/skill (must be overridden).
  • isCursorLeft(): Checks if the item window cursor is on the left side (for positioning sub-windows).
  • showSubWindow(window): Shows and activates a sub-window (like the actor window).
  • hideSubWindow(window): Hides and deactivates a sub-window.
  • onActorOk(): Handler when a target actor is confirmed. Uses the item if possible.
  • onActorCancel(): Handler when target actor selection is cancelled.
  • determineItem(): Decides whether to show the actor selection window or use the item immediately.
  • useItem(): Processes the item/skill usage (plays SE, consumes item, applies effects, etc.).
  • activateItemWindow(): Refreshes and activates the item/skill list window.
  • itemTargetActors(): Returns an array of actors targeted by the current item/skill.
  • canUse(): Checks if the user can use the selected item/skill on any valid target.
  • isItemEffectsValid(): Checks if the item/skill has a valid effect on at least one potential target.
  • applyItem(): Applies the item/skill effects to the targets.
  • checkCommonEvent(): Checks if the item/skill triggered a common event and transitions if needed.
  • playSeForItem(): Plays the sound effect for the item/skill (intended to be overridden).

Scene_Item

The scene for Browse and using items.

Methods:

  • initialize(): Constructor.
  • create(): Creates help, category, item, and actor windows.
  • createCategoryWindow(): Creates the Window_ItemCategory.
  • createItemWindow(): Creates the Window_ItemList.
  • user(): Returns the actor considered to be using the item (currently the one with the highest PHA).
  • onCategoryOk(): Handler when an item category is selected.
  • onItemOk(): Handler when an item is selected.
  • onItemCancel(): Handler when item selection is cancelled.
  • playSeForItem(): Plays the item usage sound effect.
  • useItem(): Calls the base useItem and redraws the item list.

Scene_Skill

The scene for Browse and using skills.

Methods:

  • initialize(): Constructor.
  • create(): Creates help, skill type, status, item (skill list), and actor windows.
  • start(): Refreshes the actor display.
  • createSkillTypeWindow(): Creates the Window_SkillType.
  • createStatusWindow(): Creates the Window_SkillStatus.
  • createItemWindow(): Creates the Window_SkillList.
  • refreshActor(): Updates all windows to reflect the current actor.
  • user(): Returns the currently selected actor.
  • commandSkill(): Handler when a skill type is selected.
  • onItemOk(): Handler when a skill is selected.
  • onItemCancel(): Handler when skill selection is cancelled.
  • playSeForItem(): Plays the skill usage sound effect.
  • useItem(): Calls the base useItem and refreshes windows.
  • onActorChange(): Refreshes windows when the actor is changed.

Scene_Equip

The scene for changing actor equipment.

Methods:

  • initialize(): Constructor.
  • create(): Creates help, status, command, slot, and item windows.
  • createStatusWindow(): Creates the Window_EquipStatus.
  • createCommandWindow(): Creates the Window_EquipCommand.
  • createSlotWindow(): Creates the Window_EquipSlot.
  • createItemWindow(): Creates the Window_EquipItem.
  • refreshActor(): Updates all windows for the current actor.
  • commandEquip(): Handler for the 'Equip' command.
  • commandOptimize(): Handler for the 'Optimize' command.
  • commandClear(): Handler for the 'Clear' command.
  • onSlotOk(): Handler when an equipment slot is selected.
  • onSlotCancel(): Handler when slot selection is cancelled.
  • onItemOk(): Handler when an equipment item is selected (equips the item).
  • onItemCancel(): Handler when item selection is cancelled.
  • onActorChange(): Refreshes windows when the actor is changed.

Scene_Status

The scene for viewing detailed actor status.

Methods:

  • initialize(): Constructor.
  • create(): Creates the main status window (Window_Status).
  • start(): Refreshes the actor display.
  • refreshActor(): Updates the status window for the current actor.
  • onActorChange(): Refreshes the window when the actor is changed.

Scene_Options

The scene for changing game options.

Methods:

  • initialize(): Constructor.
  • create(): Creates the options window (Window_Options).
  • terminate(): Saves the configuration changes.
  • createOptionsWindow(): Creates the Window_Options.

Scene_File

The superclass for Scene_Save and Scene_Load.

Methods:

  • initialize(): Constructor.
  • create(): Loads save file images, creates help and list windows.
  • start(): Refreshes the list window.
  • savefileId(): Returns the selected save file ID (index + 1).
  • createHelpWindow(): Creates the Window_Help.
  • createListWindow(): Creates the Window_SavefileList.
  • mode(): Returns the mode ('save' or 'load') (must be overridden).
  • activateListWindow(): Activates the save file list window.
  • helpWindowText(): Returns the text for the help window (must be overridden).
  • firstSavefileIndex(): Returns the initially selected save file index (can be overridden).
  • onSavefileOk(): Handler when a save file slot is confirmed (intended to be overridden).

Scene_Save

The scene for saving the game.

Methods:

  • initialize(): Constructor.
  • mode(): Returns 'save'.
  • helpWindowText(): Returns the save message text.
  • firstSavefileIndex(): Returns the last accessed save file index.
  • onSavefileOk(): Performs the save operation.
  • onSaveSuccess(): Handler for successful save.
  • onSaveFailure(): Handler for failed save.

Scene_Load

The scene for loading the game.

Methods:

  • initialize(): Constructor.
  • terminate(): Performs actions after loading (calls $gameSystem.onAfterLoad()).
  • mode(): Returns 'load'.
  • helpWindowText(): Returns the load message text.
  • firstSavefileIndex(): Returns the latest save file index.
  • onSavefileOk(): Performs the load operation.
  • onLoadSuccess(): Handler for successful load (plays SE, fades out, goes to map).
  • onLoadFailure(): Handler for failed load.
  • reloadMapIfUpdated(): Reloads map data if the game version has changed since saving.

Scene_GameEnd

The scene for the game end commands (To Title, Cancel).

Methods:

  • initialize(): Constructor.
  • create(): Creates the command window.
  • stop(): Closes the command window.
  • createBackground(): Creates a dimmed background.
  • createCommandWindow(): Creates the Window_GameEnd.
  • commandToTitle(): Handler for the 'To Title' command.

Scene_Shop

The scene for buying and selling items in a shop.

Methods:

  • initialize(): Constructor.
  • prepare(goods, purchaseOnly): Sets up the shop goods and purchase-only status.
  • create(): Creates all shop windows (help, gold, command, dummy, number, status, buy, category, sell).
  • createGoldWindow(): Creates the Window_Gold.
  • createCommandWindow(): Creates the Window_ShopCommand.
  • createDummyWindow(): Creates a background window shown when neither buy nor sell is active.
  • createNumberWindow(): Creates the Window_ShopNumber for quantity input.
  • createStatusWindow(): Creates the Window_ShopStatus to show item details/actor stats.
  • createBuyWindow(): Creates the Window_ShopBuy listing items for purchase.
  • createCategoryWindow(): Creates the Window_ItemCategory for selling.
  • createSellWindow(): Creates the Window_ShopSell listing items to sell.
  • activateBuyWindow(): Shows and activates the buy window.
  • activateSellWindow(): Shows and activates the sell category/list windows.
  • commandBuy(): Handler for the 'Buy' command.
  • commandSell(): Handler for the 'Sell' command.
  • onBuyOk(): Handler when an item to buy is selected.
  • onBuyCancel(): Handler when buying is cancelled.
  • onCategoryOk(): Handler when a sell category is selected.
  • onCategoryCancel(): Handler when selling category selection is cancelled.
  • onSellOk(): Handler when an item to sell is selected.
  • onSellCancel(): Handler when selling is cancelled.
  • onNumberOk(): Handler when a quantity is confirmed (performs buy/sell).
  • onNumberCancel(): Handler when quantity input is cancelled.
  • doBuy(number): Executes the purchase logic.
  • doSell(number): Executes the selling logic.
  • endNumberInput(): Hides the number window and returns to buy/sell mode.
  • maxBuy(): Calculates the maximum quantity the player can buy.
  • maxSell(): Returns the quantity of the item the player possesses.
  • money(): Returns the player's current gold.
  • currencyUnit(): Returns the currency unit symbol.
  • buyingPrice(): Returns the buying price of the current item.
  • sellingPrice(): Returns the selling price of the current item.

Scene_Name

The scene for inputting an actor's name.

Methods:

  • initialize(): Constructor.
  • prepare(actorId, maxLength): Sets the actor and max name length.
  • create(): Creates the edit and input windows.
  • start(): Refreshes the edit window.
  • createEditWindow(): Creates the Window_NameEdit.
  • createInputWindow(): Creates the Window_NameInput.
  • onInputOk(): Handler when name input is confirmed (sets actor name and pops scene).

Scene_Debug

The scene for the debug mode (F9), allowing modification of switches and variables.

Methods:

  • initialize(): Constructor.
  • create(): Creates range, edit, and help windows.
  • createRangeWindow(): Creates the Window_DebugRange (Switch/Variable selection).
  • createEditWindow(): Creates the Window_DebugEdit (Value modification).
  • createDebugHelpWindow(): Creates a window displaying controls (Window_Base).
  • onRangeOk(): Handler when a switch/variable range is selected.
  • onEditCancel(): Handler when editing is cancelled.
  • refreshHelpWindow(): Updates the help text based on the active window/mode.
  • helpText(): Returns the appropriate help text for switch or variable editing.

Scene_Battle

The scene where battles take place.

Methods:

  • initialize(): Constructor.
  • create(): Creates display objects (spriteset, windows).
  • start(): Starts fade-in, plays battle BGM, begins the battle process.
  • update(): Main update loop for the battle scene.
  • updateBattleProcess(): Updates the core battle progression via BattleManager.
  • isAnyInputWindowActive(): Checks if any command input window is active.
  • changeInputWindow(): Switches between party and actor command input as needed.
  • stop(): Handles fade-out when the battle ends.
  • terminate(): Cleans up battle resources, stops music.
  • needsSlowFadeOut(): Determines if a slow fade is needed (transitioning to Title or Gameover).
  • updateStatusWindow(): Opens/closes the status window based on message display.
  • updateWindowPositions(): Adjusts the horizontal position of the status window.
  • createDisplayObjects(): Creates spriteset and all battle windows.
  • createSpriteset(): Creates the Spriteset_Battle.
  • createAllWindows(): Creates log, status, command, help, skill, item, actor, enemy, message, and scroll windows.
  • createLogWindow(): Creates the Window_BattleLog.
  • createStatusWindow(): Creates the Window_BattleStatus.
  • createPartyCommandWindow(): Creates the Window_PartyCommand.
  • createActorCommandWindow(): Creates the Window_ActorCommand.
  • createHelpWindow(): Creates the Window_Help.
  • createSkillWindow(): Creates the Window_BattleSkill.
  • createItemWindow(): Creates the Window_BattleItem.
  • createActorWindow(): Creates the Window_BattleActor.
  • createEnemyWindow(): Creates the Window_BattleEnemy.
  • createMessageWindow(): Creates the Window_Message.
  • createScrollTextWindow(): Creates the Window_ScrollText.
  • refreshStatus(): Refreshes the status window.
  • startPartyCommandSelection(): Begins the party command phase.
  • commandFight(): Handler for the 'Fight' party command.
  • commandEscape(): Handler for the 'Escape' party command.
  • startActorCommandSelection(): Begins an actor's command selection phase.
  • commandAttack(): Handler for the 'Attack' actor command.
  • commandSkill(): Handler for the 'Skill' actor command (opens skill window).
  • commandGuard(): Handler for the 'Guard' actor command.
  • commandItem(): Handler for the 'Item' actor command (opens item window).
  • selectNextCommand(): Moves to the next actor's command input or starts the turn.
  • selectPreviousCommand(): Moves to the previous actor's command input.
  • selectActorSelection(): Activates the actor selection window.
  • onActorOk(): Handler when a target actor is confirmed.
  • onActorCancel(): Handler when actor selection is cancelled.
  • selectEnemySelection(): Activates the enemy selection window.
  • onEnemyOk(): Handler when a target enemy is confirmed.
  • onEnemyCancel(): Handler when enemy selection is cancelled.
  • onSkillOk(): Handler when a skill is confirmed.
  • onSkillCancel(): Handler when skill selection is cancelled.
  • onItemOk(): Handler when an item is confirmed.
  • onItemCancel(): Handler when item selection is cancelled.
  • onSelectAction(): Called after a skill/item is chosen; proceeds to target selection or next command.
  • endCommandSelection(): Closes command windows when input phase ends.

Scene_Gameover

The scene displayed when the party is defeated.

Methods:

  • initialize(): Constructor.
  • create(): Plays game over music and creates the background.
  • start(): Starts the fade-in.
  • update(): Checks for input to return to the title screen.
  • stop(): Fades out all visuals and audio.
  • terminate(): Stops all audio.
  • playGameoverMusic(): Plays the game over ME.
  • createBackground(): Creates the game over background sprite.
  • isTriggered(): Checks for confirmation input (OK or Touch).
  • gotoTitle(): Transitions back to the title screen.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment