This is more of a JS question really. I know the solution, I just need to know why this won't work, opposed to that.
I am very new to PIXI and just barely grasping the concepts of oop so bare with me. What I'm wanting to build is an array based keyframe animation system ie (player.add.animations([3.5.9.10], walk, fps)). Of course I don't really like using game engines because I feel like I won't really be "learning" anything.
let Container = PIXI.Container,
autoDetectRenderer = PIXI.autoDetectRenderer,
loader = PIXI.loader,
resources = PIXI.loader.resources,
Sprite = PIXI.Sprite;
icon = function(img, type){
var self = {
img: img,
type: type
};
return self;
};
icon.prototype = Object.create(Sprite);
icon.prototype.animate = function(){
console.log("test");
};
var meow = icon("rwqerq" , "asdf");
meow.animate();
So I was wondering why meow didn't inherit the .animate method, the console says its a function. I know that removing "var self = {}" and "return self;" will fix the problem, along with using "this.img = img;" and the "new" keyword will fix this problem, but again, I just want to know why this doesn't work opposed to the solution, so I can expand my general js knowledge.