Skuzzi

Phaser runs extremely inconsistently

Recommended Posts

I really liked Phaser and wanted to use it for game development but I find it to be impossible because of this issue.

I'm using Chrome primarily and even with the most basic examples using just body.velocity to move a sprite around it is choppy at times.

I can't figure out when and why it is choppy, but basically 30% of the time or so, the sprite is just moving choppily even at 60FPS.

The issue also seems to be replicable when I switch back and forth between the tab the game is on and another random tab.

I also encountered another issue where the game would just run at 30FPS for no reason and then suddenly start running at 60FPS.

I would love to use Phaser but these issues make me want to consider a traditional desktop environment, are there anyone else with these issues that might have a fix?

I know about the "forceSingleUpdate" fix but I don't want any users to suffer potential physics calculation issues.

I would also like to note that my computer shouldn't be the issue, but my specs are: i5-2500k @ 4.6Ghz, 2x Radeon HD 6970 (4GB VRAM total), 8GB DRAM. Running on Windows 7 on an Intel 128GB SSD.

Share this post


Link to post
Share on other sites
var game = new Phaser.Game(672, 672, Phaser.AUTO, '');

var map;
var layer;
var player;
var cursors;

var mainState = {
  preload: function() {
    // Load in tilemap data
    game.load.tilemap('testmap', 'levels/pacmanlevel.json', null, Phaser.Tilemap.TILED_JSON);

    // Load in tileset
    game.load.image('tiles', 'assets/pacmansprite.png');
    game.load.image('player', 'assets/pacman.png');
  },

  create: function() {
    game.time.advancedTiming = true;
    game.stage.backgroundColor = '#000000';

    map = game.add.tilemap('testmap', 512, 512);
    map.addTilesetImage('pacmansprite', 'tiles');
    layer = map.createLayer(0);
    layer.resizeWorld();

    player = game.add.sprite(32, 32, 'player');
    game.physics.enable(player);

    cursors = game.input.keyboard.createCursorKeys();
  },

  update: function() {
    game.debug.text(game.time.fps || '--', 2, 14, "#00ff00");
    if (cursors.up.isDown) {
      player.body.velocity.x = 0;
      player.body.velocity.y = -200;
    }
    else if (cursors.down.isDown) {
      player.body.velocity.x = 0;
      player.body.velocity.y = 200;
    }
    else if (cursors.left.isDown) {
      player.body.velocity.y = 0;
      player.body.velocity.x = -200;
    }
    else if (cursors.right.isDown) {
      player.body.velocity.y = 0;
      player.body.velocity.x = 200;
    }
  },
};

game.state.add('mainState', mainState);
game.state.start('mainState');

Here the code is. It does however run fine with forceSingleUpdate. If that does not cause any issues that will be a good solution.

And I had the same problems in both IE / Chrome. Did not try Firefox. I can try on Firefox if anyone is interested.

Share this post


Link to post
Share on other sites
4 hours ago, Skuzzi said:

 

The issue also seems to be replicable when I switch back and forth between the tab the game is on and another random tab.

 

Your code looks fine to me. You can add (in create)

game.stage.disableVisibilityChange = true;

as well so your game runs while the browser is unfocused (not minimized).  

4 hours ago, Skuzzi said:

I would love to use Phaser but these issues make me want to consider a traditional desktop environment,

 If you want to the game to continue to run while minimized you will need to use the latest NW.js SDK and add "chromium-args" : "--disable-raf-throttling",
to your package.json.  This should help with your 'Desktop Environment' feeling. These tricks can make it seem like a 'native' app :) 

Share this post


Link to post
Share on other sites
15 hours ago, rich said:

forceSingleUpdate would *not* cause physics calculation issues at all. In fact it's now enabled by default in 2.4.7 and on.

Any updates on when 2.4.7 will be released? It seems like it's going to improve a lot of things about Arcade physics!

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

  • Recently Browsing   0 members

    No registered users viewing this page.