Kryeger Posted June 19, 2018 Share Posted June 19, 2018 I'm working my way through the firstgame tutorial and, for unknown reasons, I can't call .refreshBody(). Everything else works as intended, but this doesn't want to. Relevant snippet: //in create() function this.add.image(400, 300, "sky"); platforms = this.physics.add.staticGroup(); platforms.create(400, 568, 'ground').setScale(2).refreshBody(); // <-- platforms.create(600, 400, "ground"); platforms.create(50, 250, "ground"); platforms.create(750, 220, "ground"); player = this.physics.add.sprite(100, 450, 'dude'); player.setBounce(0.2); player.setCollideWorldBounds(true); player.body.setGravityY(300); this.physics.add.collider(player, platforms); and the error game.js:46 Uncaught TypeError: platforms.create(...).setScale(...).refreshBody is not a function at initialize.create (game.js:46) at initialize.create (phaser.min.js:1) at initialize.loadComplete (phaser.min.js:1) at initialize.h.emit (phaser.min.js:1) at initialize.processComplete (phaser.min.js:1) at initialize.removeFromQueue (phaser.min.js:1) at initialize.processUpdate (phaser.min.js:1) at Image.data.onload (phaser.min.js:1) create @ game.js:46 create @ phaser.min.js:1 loadComplete @ phaser.min.js:1 h.emit @ phaser.min.js:1 processComplete @ phaser.min.js:1 removeFromQueue @ phaser.min.js:1 processUpdate @ phaser.min.js:1 data.onload @ phaser.min.js:1 load (async) onProcess @ phaser.min.js:1 (anonymous) @ phaser.min.js:1 each @ phaser.min.js:1 finishedLoading @ phaser.min.js:1 nextFile @ phaser.min.js:1 onLoad @ phaser.min.js:1 load (async) t.exports @ phaser.min.js:1 load @ phaser.min.js:1 loadFile @ phaser.min.js:1 (anonymous) @ phaser.min.js:1 each @ phaser.min.js:1 processLoadQueue @ phaser.min.js:1 nextFile @ phaser.min.js:1 onLoad @ phaser.min.js:1 load (async) t.exports @ phaser.min.js:1 load @ phaser.min.js:1 loadFile @ phaser.min.js:1 (anonymous) @ phaser.min.js:1 each @ phaser.min.js:1 processLoadQueue @ phaser.min.js:1 start @ phaser.min.js:1 bootScene @ phaser.min.js:1 start @ phaser.min.js:1 add @ phaser.min.js:1 processQueue @ phaser.min.js:1 h.emit @ phaser.min.js:1 updatePending @ phaser.min.js:1 h.emit @ phaser.min.js:1 n.onload @ phaser.min.js:1 load (async) addBase64 @ phaser.min.js:1 boot @ phaser.min.js:1 h.emit @ phaser.min.js:1 boot @ phaser.min.js:1 e @ phaser.min.js:1 setTimeout (async) t.exports @ phaser.min.js:1 initialize @ phaser.min.js:1 (anonymous) @ game.js:23 The "platform" variable is declared just above the function. Any help would be greatly appreciated. I'm attaching the whole source just in case. game.js Link to comment Share on other sites More sharing options...
rich Posted June 20, 2018 Share Posted June 20, 2018 Code looks fine at a cursory glance. What happens if you replace your code with the actual code from the tutorial files? Link to comment Share on other sites More sharing options...
Kryeger Posted June 20, 2018 Author Share Posted June 20, 2018 I've only copy pasted from the tutorial (altering only the resource locations, which work) and as I reach part 4, the part which uses the refreshBody function, I get the same error. The error looks like this: game.js:42 Uncaught TypeError: platforms.create(...).setScale(...).refreshBody is not a function at initialize.create (game.js:42) at initialize.create (phaser.min.js:1) at initialize.loadComplete (phaser.min.js:1) at initialize.h.emit (phaser.min.js:1) at initialize.processComplete (phaser.min.js:1) at initialize.removeFromQueue (phaser.min.js:1) at initialize.processUpdate (phaser.min.js:1) at Image.data.onload (phaser.min.js:1) I am attaching the source file as well. Just in case, here is my index.html: <!DOCTYPE html> <html> <head> <script src="//cdn.jsdelivr.net/npm/[email protected]/dist/phaser.min.js"></script> <script src="js/game.js"></script> </head> <body> </body> </html> game.js Link to comment Share on other sites More sharing options...
rich Posted June 20, 2018 Share Posted June 20, 2018 Ahh, I see - it's the version of Phaser you're using. Swap it for the new one (replace 3.0.0 with 3.10.1) in the cdn line. Link to comment Share on other sites More sharing options...
Kryeger Posted June 20, 2018 Author Share Posted June 20, 2018 That did it! Thanks! Link to comment Share on other sites More sharing options...
Recommended Posts