I want to know when to create a class in your RMMV plugin and when not to?
MV When to create a class for an RPG Maker MV plugin?
Learning JavascriptAlways. So bloody convenient.
After I started doing classes (plus inheritance), I eliminated all standalone functions.
Even RPGM's functions are wrapped inside of a "RPGM_API_Wrappers" class as static functions.
On top of it, I use classes for namespace control, such as:
You won't regret one bit going with classes.
After I started doing classes (plus inheritance), I eliminated all standalone functions.
Even RPGM's functions are wrapped inside of a "RPGM_API_Wrappers" class as static functions.
On top of it, I use classes for namespace control, such as:
JavaScript:
class cnst{
static text_initialized = 'INITIALIZED'
static text_uninitialized = 'UNINITIALIZED'
static text_cancel = 'CANCEL'
}
You won't regret one bit going with classes.
If you decide to use classes, then do use the proper Class syntax, and avoid either the prototyping or the "object" (i.e. this: {}) approaches.
Here is the Class syntax.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes
Here is the Class syntax.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes
RPG maker barely uses any "class", more often, it defines a function by name, adds a constructor, and some properties. Check Game_Actor for example.
Original thread: https://forums.rpgmakerweb.com/threads/when-to-create-a-class-for-an-rpg-maker-mv-plugin.140367/