I've made a constructor (and put it above preload function) like this
character = function(CharX,CharY,CharSpeed){
this.x = CharX ;
this.y = CharY;
this.speed = CharSpeed;
this.AddSpriteSheet = function (SprX,SprY,key) {
this.character = game.add.sprite(SprX,SprY,key);}
};
Later in create function I added
var Char1 = new character(game.world.width*0.5,game.world.height*0.5,5);
Char1.AddSpriteSheet(game.world.width*0.5,game.world.height*0.5,'character');
Char1.anchor.set(50,50);
Console reads
"Uncaught TypeError: Cannot read property 'set' of undefined"
What have i done wrong?
Edit : Make error more visible
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…