The ability to add methods to a prototype is extremely useful, especially in Screeps. See more prototypes like Room, Source, and Structure. This is how all in game objects have their properties and methods defined. All of your creep objects have a link to this prototype and therefore inherit from it. All of these properties and methods are accessible to all of your creeps only because they are defined on the Creep prototype. The Creep prototype has many useful properties and methods defined that you are familiar with such as. If you had created a creep named "John", then would have a link to the Creep prototype. Alternatively, a prototype may also be null. Being another object itself, the prototype object may also have a link to another prototype object, creating a prototype chain. Prototypes are what allow for inheritance in Javascript and can be used in many powerful ways.Įvery object in Javascript has a link to another object called a prototype object from which it inherits properties and methods. This article will discuss object prototypes and several ways that they can be used/modified to make your life a little easier in Screeps! What are prototypes?
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |