predator Posted January 3, 2017 Share Posted January 3, 2017 When I am running the following code, my browser (chrome) returns an error when I try to run setPreloadSprite. The error is Uncaught TypeError: Cannot read property 'width' of undefined When I am trying to run this.preloadbg = this.add.sprite(this.game.world.centerX, this.game.world.centerY, 'loadbg'); console.log('reached'); this.preloadbg.anchor.setTo(0.5); this.preloadbg.scale.setTo(10); this.preloadbar = this.add.sprite(this.game.world.centerX, this.game.world.centerY, 'loadbar'); this.preloadbar.anchor.setTo(0.5); this.preloadbar.scale.setTo(10); this.load.setPreloadSprite(this.preloadBar); Why is this error coming? When I look at the error text, it says it is coming from the 'phaser.js' file. Is there really that big of a bug? Link to comment Share on other sites More sharing options...
samme Posted January 3, 2017 Share Posted January 3, 2017 You should be able to expand the error message and find the line in your code closest to the error. I think you misspelled `preloadbar` in the last line. Link to comment Share on other sites More sharing options...
predator Posted January 4, 2017 Author Share Posted January 4, 2017 Oh yeah, rip me. Thanks for the help! I can't believe it. I have to work on my camelcase. I guess I'm just too lazy to press the shift key... Link to comment Share on other sites More sharing options...
Recommended Posts