Jump to content

Perfomance Question


litecoinDude
 Share

Recommended Posts

Hello everyone!

 

I'm totally new to game development.
I started playing around with Phaser and came to the Motion Demo in the physics section from the examples. 
 
I modified the alien sprite physics that it seems some bombs are dropping from the sky ;-)
 
My Question is, why it´s starting to lag as soon as i add more aliens? Maybe 600-800
 
In the bunny demo from pixijs i can add thousands of bunnys and still have 60fps
 
This is my Code
(function () {    var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create, update: update});    function preload() {        game.load.image('baddie', 'assets/sprites/space-baddie.png');          game.load.tilemap('level1', 'assets/games/starstruck/tiles-1.png', 'assets/games/starstruck/level1.json', null, Phaser.Tilemap.JSON);    }          var aliens;    var map;    function create() {              map = game.add.tilemap(0, 0, 'level1');        map.setCollisionRange(1, 12, true, true, true, true);        map.setCollisionRange(18, 47, true, true, true, true);        map.setCollisionRange(53, 69, true, true, true, true);                aliens = game.add.group();        for (var i = 0; i < 50; i++)        {            var s = game.add.sprite(game.world.randomX, game.world.randomY, 'baddie');            s.name = 'alien' + s;              s.body.bounce.y = 0.3;            s.body.velocity.x=100;            s.body.gravity.y = 15;            aliens.add(s);           // aliens.push(s);        }          }    function update() { game.physics.collide(aliens, map,collisionHandler, null, this);                     if (game.input.keyboard.isDown(Phaser.Keyboard.UP))        {            for (var i = 0; i < 50; i++)            {                var s = game.add.sprite(game.world.randomX, game.world.randomY, 'baddie');                s.name = 'alien' + s;                      s.body.bounce.y = 0.3;                s.body.velocity.x=100;                s.body.gravity.y = 15;                aliens.add(s);               // aliens.push(s);            }        }    }    function collisionHandler(aliens,map){    }})();

thanks for any tipps and the cool framework!!!

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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