Jump to content

How to generate random sprite in phaser


Recommended Posts

I have a function 'randomTiles();' which is meant to generate random falling tiles (like rain drops) from the top of the page downwards, what happens is the tile are generated randomly from different areas of the game window, also this isn't working 'sprite1.body.setSize(50, 26, 0, 0);' I don't why.

here is what I have done

function releaseTiles() {

//sprite1 = game.add.sprite(300, 50, 'tile');
sprite1 = game.add.sprite((Math.random() * 20000), game.world.randomY, 'tile');
sprite1.name = 'tile';
game.physics.enable(sprite1, Phaser.Physics.ARCADE);
sprite1.body.velocity.y = 100;
sprite1.body.setSize(50, 26, 0, 0);


Link to comment
Share on other sites


  • Recently Browsing   0 members

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