Jump to content
This forum will be closing down. Please move to the respective dedicated project forums.

how to animate a group of clouds


hugo
 Share

Recommended Posts

hello!

 

i'm trying to animate a group of clouds in the sky
and i want to make it loop 
how can i do this 
 
here's my code so far
 
<!DOCTYPE html><html> <head>    <meta charset="utf-8" />    <title>clouds</title>    <script type="text/javascript" src="phaser.min.js"></script></head><body>    <div id="gameContainer"> </div>    <script type="text/javascript">        var game = new Phaser.Game(800, 600, Phaser.AUTO, 'phaser-example', { preload: preload, create: create, update: update });        function preload() {            game.load.image('background', 'assets/background.png');            game.load.image('plane', 'assets/plane.png');            game.load.image('cloud', 'assets/cloud.png');        }        var plane;        var clouds;        function create() {                      game.add.image(0, 0, 'background');                        game.physics.startSystem(Phaser.Physics.ARCADE);            game.physics.arcade.gravity.y = 10;                        plane = game.add.sprite(100, 96, 'plane');                        game.physics.enable(plane, Phaser.Physics.ARCADE);                        clouds = game.add.group();                        for (var i = 0; i < 60; i++)            {                sprite = clouds.create(120 * i, game.world.randomY, 'cloud');                game.physics.enable(sprite, Phaser.Physics.ARCADE);                sprite.body.allowGravity = false;                sprite.body.velocity.x = -150;            }        }        function update () {                         if (plane.outOfBoundsKill == true)                game.state.restart();         }                function restart () {                    }            </script></body></html>
Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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