Jump to content

Apply gravity on image read from atlas


kray
 Share

Recommended Posts

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 = 200

I get an error saying 'Cannot read property gravity of null'. Don't atlases have bodies?

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...