Indie Dev

Hello Guest!. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, sell your games, upload content, as well as connect with other members through your own private inbox!

Template for creating a scene

eivl

Local Hero
Xy$
0.00
Thanks to nio kasgami for writing this. I found it very useful!

JavaScript:
//==============================================================================
// ■ Scene_Test
//------------------------------------------------------------------------------
  // this a dummy Scene for show structure.
//==============================================================================

function Scene_Test(){this.initialize.apply(this,arguments);}

//----------------------------------------------------------------------------
// ◎ new inheritance : SceneMenuBase
//----------------------------------------------------------------------------
//<"Makes Scene_Test inherit the functions and properties of  Scene_MenuBase">
//----------------------------------------------------------------------------
Scene_Test.prototype = Object.create(Scene_MenuBase.prototype);

//----------------------------------------------------------------------------
// ◆ new constructor: Scene_Test
//----------------------------------------------------------------------------
// tell the function constructor is Scene_Test
//----------------------------------------------------------------------------
Scene_Test.prototype.constructor = Scene_Test;


//----------------------------------------------------------------------------
// ○ new function: prepare
//----------------------------------------------------------------------------
// <"Permits to transfert external values from event scripts calls in game.">
//----------------------------------------------------------------------------
Scene_Test.prototype.prepare = function(ai_id) {
     this.scene_id = ai_id;
};

//----------------------------------------------------------------------------
// ○ new function: initialize
//----------------------------------------------------------------------------
// <"Sets the default values of the scene">
// EXTRA : <"Always do inheritance with your Scene initialize function
// it's important!">
//----------------------------------------------------------------------------
Scene_Test.prototype.initialize = function() {
     Scene_MenuBase.prototype.initialize.call(this);
};

//----------------------------------------------------------------------------
// ○ new function: start
//----------------------------------------------------------------------------
// <"it's set's the flag ready and start the scene always do inheritance.">
//----------------------------------------------------------------------------
Scene_Test.prototype.start = function() {
     Scene_MenuBase.prototype.start.call(this);
}

//----------------------------------------------------------------------------
// ○ new function: create
//----------------------------------------------------------------------------
// <"Serve for create your scene contents and to load it in your scene.">
//---------------------------------------------------------------------------
Scene_Test.prototype.create = function() {
     Scene_MenuBase.prototype.create.call(this);
     this.get_ai_data();
     this.create_window();
};

//----------------------------------------------------------------------------
// ○ new function: update
//----------------------------------------------------------------------------
// <"Update the Scene.">
//---------------------------------------------------------------------------
Scene_Test.prototype.update = function() {
    Scene_MenuBase.prototype.update.call(this);
};

//----------------------------------------------------------------------------
// ○ new function: terminate
//----------------------------------------------------------------------------
// <"dispose the content of the scene">
//---------------------------------------------------------------------------
Scene_Test.prototype.terminate = function() {
    Scene_MenuBase.prototype.terminate.call(this);
};

/////////////////////////////////////////////////////////////
// personal function
// <"Unrelated to the tutorial.">
////////////////////////////////////////////////////////////
Scene_Test.prototype.get_ai_data = function() {
     $game_personalities.get_personality(this.scene_id);
};

Scene_Test.prototype.create_window = function() {
     this.message_window = new Window_Message();
};
Mandatory functions

  • initialize : this function is the core of your scene it's what who actually initialize your function but it's can rename like you want...but for permit inheritance with MV function and comprehension better name it initialize.
  • create : This section is the place where you create and load all your contents Ojima setup the SceneManager make call create when loading the scene. So it's better to input all your "create" and load method in this.
  • start : it's the function who actually start the scene without this one your scene wouldn't run at all.
  • update : it's the function who update your screen it's inherit of important option for your scene so be sure to add it with all the inheritance who go with it.


Non mandatory

  • terminate : it's the function who Dispose all your content Specially your sprite at the end of the scene. it's not forced to add to the Scene function if you don't dispose anything's.
  • prepare : casual function used in ace...it's was used to get named like you want but now you are forced to name it prepare due how SceneManager is handle...In simple this method serve for transfer data from a event script call to the Scene Function...use it when you absolutely need to transfer data. Unless that it's not useful.
  • isBusy : this one serve for the Fadein time don't add it unless you want to change the time you transfer your scene.
 

Boy Who Codes

Praised Adventurer
Xy$
0.00
Nice post. This is useful for many, that's for sure. Actually all we need is already in the default scripts and all we need to do is take a quick look at them. I was even trying to do some overlay only to find out everything can be replicated from the default scripts.
 

Status Gear Entertainment

Praised Adventurer
So for dummies like me, I can make HUD displays with this right? I can actually display multiple scenes on a single screen? I apologize for my lack of knowledge in this field, but if this is headed where I think it is, this could most likely be what I desire to coding.
 

eivl

Local Hero
Xy$
0.00
Nice post. This is useful for many, that's for sure. Actually all we need is already in the default scripts and all we need to do is take a quick look at them. I was even trying to do some overlay only to find out everything can be replicated from the default scripts.
Yeah, you are so correct. It is more helpful to ready the core files. Main problem with the core files is the lack of documentation.
This is why you need a good IDE so you can find all dependencies up the prototypal chain.
 
It is more helpful to ready the core files. Main problem with the core files is the lack of documentation. This is why you need a good IDE so you can find all dependencies up the prototypal chain.
And it's very useful doing so, for novices and pros alike. The console.log is also extremely useful for pinpointing exactly what went wrong, where and why (even if its error messages are sometimes obscure).
 

cav_dan

Towns Guard
Nice one! A question, are those comments structured in a way that we can create a documentation later?

Also, preferred IDE is Sublime Text, right? Any plugins that can help trace function calls and such?
 

eivl

Local Hero
Xy$
0.00
Nice one! A question, are those comments structured in a way that we can create a documentation later?

Also, preferred IDE is Sublime Text, right? Any plugins that can help trace function calls and such?
Yes, that is the idea ;)

Sublime Text is nice for easy small projects, like plugins for MV.

For big projects on an enterprise level you would have to choose something else.
 

eivl

Local Hero
Xy$
0.00
Yes if you are a single developer, i am thinking of webstorm, even though i use it alot i like sublime better..
 

Boy Who Codes

Praised Adventurer
Xy$
0.00
So... Eclipse then. :3
I like Eclipse for full scale development. Though I have to remind you that if you're using it for MV only, I suggest you use something lightweight for your computer. Something like Brackets. I like Brackets more than Sublime, reason being it can trace ALL other functions you've made from the root folder you've created. In sublime, it goes singularly.
 

trapless

Villager
Xy$
0.00
RPG Maker MV 1.6.0 updated NW.js allowing Windows versions to support ES6 syntax. Most if not all modern web browsers do too.

Here is a link to an ES6 scene template.

P.S. (.prepare) can be examined in Scene_Name and Scene_Shop.
 
Top