- Home /
Defining and inheriting from a Javascript Class
Here's my problem:
Every object in my game has an "ObjectScript.js" which defines the properties of that object. This script has a function called "MyAction" which defines what that particular object should do.
I want to create a unique script for every object type that inherits its properties from ObjectScript.js but override the "MyAction" function with custom script.
Example: ObjectScript.js (Defines properties and functions of all objects)
---function MyAction(){...defines default function}
Character.js - inherits from ObjectScript.js
---function MyAction() {...overrides the default script in the inherited function}
Seems like this should be easy and I have seen a few examples but I just not understanding it. Can anyone give me an example of how this works or suggest a better method for inheriting script functions?
Thanks in advance.