robkof Posted July 24, 2016 Share Posted July 24, 2016 Hi! Im new to Javascript game programming and Phaser. I am running in to a problem when i try to create a class which inherits from Phaser.Sprite So I load my image: this.load.image('face','assets/face.jpg') I create the class (from the official Monsterbunny example): Enemy = function (game, x, y, spritename) { Phaser.Sprite.call(this, game, x, y, spritename); this.anchor.setTo(0.5, 0.5); this.scale.setTo(1, 1) game.add.existing(this); }; Enemy.prototype = Object.create(Phaser.Sprite.prototype); Enemy.prototype.constructor = Enemy; Enemy.prototype.update = function () { }; And then add it to the game with: new Enemy(game,500,500,'face') But when the code runs, I get error msg: Quote Uncaught TypeError: Cannot read property 'getImage' of undefined At the line of which the Phaser.Sprite.call(this, game, x, y, spritename); I have the newest version of Phaser. Thx for all the help in advance! Link to comment Share on other sites More sharing options...
Recommended Posts