ashebby Posted June 30, 2015 Share Posted June 30, 2015 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 donefunction 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 More sharing options...
MrRoboman Posted June 30, 2015 Share Posted June 30, 2015 What are asking? Are you asking why 'sprite1.body.setSize(50, 26, 0, 0);' doesn't work? And, out of curiosity, why are you using (Math.random() * 20000) instead of game.world.randomX? 20000 is way too big a number. Most of your sprites will spawn off screen. Link to comment Share on other sites More sharing options...
Recommended Posts