JSFiddle - React, Tailwind, and code Playground
JavaScript
// Hi, thanks for your time :-)
function Node() {
console.log('running node constructor');
}
function GameObject() {
// Call to "super()"
Node.call(this);
console.log('running gameobject constructor');
this.animations = {};
}
var TempCtor = function(){};
TempCtor.prototype = Node.prototype;
GameObject.prototype = new TempCtor();
GameObject.prototype.constructor=GameObject;
var idx = 0;
function Redhead() {
// Call to "super()"
GameObject.call(this);
console.log('running player constructor');
this.animations['running'] = ("myRunningAnim" + idx++);
}
TempCtor.prototype = GameObject.prototype;
Redhead.prototype = new TempCtor();
Redhead.prototype.constructor=Redhead;
var player1 = new Redhead();
var player2 = new Redhead();
var player3 = new Redhead();
console.log('Must be item 0, is actually ' + player1.animations['running']);
console.log('Must be item 1, is actually ' + player2.animations['running']);
console.log('Must be item 2, is actually ' + player3.animations['running']);