killer_manatee Posted October 4, 2017 Share Posted October 4, 2017 Hi all, Brand new to phaser. When I do: katamari = game.add.sprite(32, game.world.height - 150, 'katamari'); it works great, but when I refactor to make my code prettier/more object oriented: function Unit(game, x, y, spriteName) { Phaser.Sprite.call(this, game, x, y, 'units', spriteName); // base unit stuff goes here } Unit.prototype = Object.create(Phaser.Sprite.prototype); Unit.prototype.constructor = Unit; ... katamari = new Unit(game, 32, game.world.height - 150, 'katamari'); game.add.existing(katamari); The sprite image fails to load. I am preloading the image correctly because it works in the first case. I have no idea why this is happening. Thanks Edit: Realized issue in constructor, would delete if forum allowed Link to comment Share on other sites More sharing options...
Recommended Posts