Hope this don’t sound to stupid but kinda new to javascript, what I want to do is build an entity based on mostly one script … this script should inherit all functions and variables from another script from any directory from any file.
A very basic example …
var Ship = pc.createScript('Ship');
// Base object for any entity floating on water
// initialize code called once per entity
Ship.prototype.initialize = function() {
this.name = "Hello from Ship";
console.log(name);
};
// update code called every frame
Ship.prototype.update = function(dt) {
};
now in another file I have this …
var Carrier= pc.createScript('Carrier');
// Can I some how extend Sip?
Carrier = new pc.script.ship(); // nope
Carrier = new Object.create(Ship); // nope
Carrier = new Ship(); // nope
ect ...
// initialize code called once per entity
Carrier.prototype.initialize = function() {
console.log(name);
};
// update code called every frame
Carrier.prototype.update = function(dt) {
};
I guess what I’m getting at is as I build functionality I find myself attaching many scripts to my entities, creating clutter … I’m assuming there is a way to break this all down into base objects and build from there. So if I created a Carrier entity all I’d have to do is attach the Carrier script to the entity there for inheriting all the functions and var from Ship.
Thanks !!!