Jump to content

Asteroids disappear in main menue


El Krusto
 Share

Recommended Posts

Hi guys,
 
I want to create a menu screen with flying asteriods, when they leave the screen, they should appear on the opposite side.
 
I thought this should be done automatically when i use Phaser.Physics.ARCADE, but saidly it doesn't work.

My menu looks like this:
function menu () {	var background = game.add.tileSprite(0, 0, viewportWidth, viewportHeight, 'space');	background.autoScroll(5,+10)		// random asteroids	var asteroids = game.add.group();	asteroids.enableBody = true;	asteroids.physicsBodyType = Phaser.Physics.ARCADE;    for (var i = 0; i < 15; i++)    {        var asteroid = asteroids.create(game.world.randomX, game.world.randomY, 'asteroide', 0);        var asteroidSize = Math.random() * (1.1 - 0.5) + 0.5;        asteroid.scale.set(asteroidSize, asteroidSize);                asteroid.body.velocity.x = getRandomArbitrary(-50, 100);        asteroid.body.velocity.y = getRandomArbitrary(-50, 100);    	asteroid.body.angularVelocity = getRandomArbitrary(-50, 50);        asteroid.anchor.setTo(0.5, 0.5);                //This allows your sprite to collide with the world bounds like they were rigid objects        //asteroid.body.collideWorldBounds=true;        //asteroid.body.bounce.setTo(1, 1);    }}
Thx
Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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