Aliasing the xManager functions

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,108
Reaction score
13,713
First Language
English
Primarily Uses
RMMV
What is the difference between a function specified as a prototype and one that's not?  For example, 


Tilemap.prototype._sortChildren = function()


and 


Tilemap.isVisibleTile = function(tileId)


Can I alias both of them, and do I alias them and call them in the same way?


When I call the aliased function, how do I know whether I have to pass in this as a first parameter, and when I don't?  Tilemap.isVisibleTile uses this.TILE_ID_MAX so I assume whether I pass in this has nothing to do with whether it's a prototype function?
 

Kino

EIS Game Dev
Veteran
Joined
Nov 27, 2015
Messages
556
Reaction score
795
First Language
English
Primarily Uses
RMMV
The difference between the prototype and the other type of function is that a prototype requires you create a new object to use that function call,  and the other type is accessible only by calling the  Function itself.


Prototypes are good, cause you can do inheritance for objects, make multiple objects.


The other one is great for a static class like the DataManager, which you only want a single instance of.


Also you are correct, this has nothing to do with it being a prototype or not. If you use strict mode, "this" will be different depending on where it's called.


Think of  "this" as the box in which your code will run.


Rule of thumb  though : pass "this" to a function inside a function,  like when you alias and call a prototype. Otherwise,  no need to use "this", while calling,  since it applies the code to that object(this).


On aliasing,  you can alias it as a variable I believe. I do it often with the DataManager  class.
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,108
Reaction score
13,713
First Language
English
Primarily Uses
RMMV
Thank you :)
 

Dr.Yami

。◕‿◕。
Developer
Joined
Mar 5, 2012
Messages
1,003
Reaction score
757
First Language
Vietnamese
Primarily Uses
Other
Think prototype is like class method, and without prototype is like module/namespace function. :)
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,108
Reaction score
13,713
First Language
English
Primarily Uses
RMMV
Ah, nice, easy explanation.  Thanks @Dr.Yami :)
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Profile Posts

Our latest feature is an interview with... me?!

People4_2 (Capelet off and on) added!

Just beat the last of us 2 last night and starting jedi: fallen order right now, both use unreal engine & when I say i knew 80% of jedi's buttons right away because they were the same buttons as TLOU2 its ridiculous, even the same narrow hallway crawl and barely-made-it jump they do. Unreal Engine is just big budget RPG Maker the way they make games nearly identical at its core lol.
Can someone recommend some fun story-heavy RPGs to me? Coming up with good gameplay is a nightmare! I was thinking of making some gameplay platforming-based, but that doesn't work well in RPG form*. I also was thinking of removing battles, but that would be too much like OneShot. I don't even know how to make good puzzles!
one bad plugin combo later and one of my followers is moonwalking off the screen on his own... I didn't even more yet on the new map lol.

Forum statistics

Threads
106,034
Messages
1,018,446
Members
137,820
Latest member
georg09byron
Top