LuckieLordie Posted November 1, 2013 Share Posted November 1, 2013 Hi all! I've been trying to recreate the Extending a Sprite example and I think I'm having trouble with where to put my source code to keep things in scope. Pokeball.jsPokeBall = function (game, rotateSpeed) { Phaser.Sprite.call(this, game, game.world.randomX, game.world.randomY, 'pokeball'); this.anchor.setTo(0.5, 0.5); this.rotateSpeed = rotateSpeed; var randomScale = 0.1 + Math.random(); this.scale.setTo(randomScale, randomScale) game.add.existing(this);};PokeBall.prototype = Object.create(Phaser.Sprite.prototype);PokeBall.prototype.constructor = PokeBall;PokeBall.prototype.update = function() { // Automatically called by World.update this.angle += this.rotateSpeed;};Game.jsMissileMania.Game = function (game) { };MissileMania.Game.prototype = { quitButton: null, create: function () { this.quitButton = this.game.add.button(0, 0, 'button_sprite', quitOnClick, this, 0, 1, 2); function quitOnClick() { this.game.state.start('MainMenu'); } for(var i = 1; i < 20; i++) { new Pokeball(this.game, i); } }, update: function () { }, shutdown: function() { this.quitButton.destroy(); this.quitButton = null; }};These two files are included in my index.html. However when my browser tried to execute line 21 of Game.js It says "Pokeball is not defined" Link to comment Share on other sites More sharing options...
rich Posted November 1, 2013 Share Posted November 1, 2013 It's case sensitive. You've called your object PokeBall, but in your Game you call it Pokeball. Link to comment Share on other sites More sharing options...
LuckieLordie Posted November 1, 2013 Author Share Posted November 1, 2013 It's case sensitive. You've called your object PokeBall, but in your Game you call it Pokeball.Maaaaan. I am on a roll this week xD Thanks Rich! I'll not fall for that one day! Link to comment Share on other sites More sharing options...
Recommended Posts