kray Posted April 7, 2015 Share Posted April 7, 2015 In my game, I need letters to fall from the sky. For the letters, I have created an atlas. The problem is, I cannot apply gravity on those letters. I'm reading images as:this.load.atlas('alphabets','asset/letters.png','asset/letters.json');var img = (String.fromCharCode((Math.floor(Math.random()*100)%26)+97))+'.png'; var x = Math.floor(Math.random()*1000)%this.world.width; // Create a star inside of the 'stars' group var letter = this.add.sprite(x, 0, 'alphabets'); //letter.frameName = img;On typing letter.body.gravity.y = 200I get an error saying 'Cannot read property gravity of null'. Don't atlases have bodies? Link to comment Share on other sites More sharing options...
MikeT Posted April 7, 2015 Share Posted April 7, 2015 You must enable physics on it first and that will create the body.game.physics.enable(letter, Phaser.Physics.ARCADE); Link to comment Share on other sites More sharing options...
Recommended Posts