georgenasr87 Posted April 25, 2015 Share Posted April 25, 2015 Hi,I'm developing an html5 game using phaser + cocoonjs. So far there is only 1 sprite with velocity set, so basically it just moves from right to left. As simple as it sounds, running this on android device (and sometimes in chrome) I noticed that the sprite doesn't move smoothly, it's laggy! I'm not sure if there is a better way to animate the sprite that makes it smooth. Here is the code I have, I also attached the full application. /// <reference path="js/phaser.min.js" />var w = window.innerWidth;var h = window.innerHeight; var game = new Phaser.Game(w, h, Phaser.AUTO, '', { preload: preload, create: create, update: update });var speed = -250; function preload() { game.load.image('trainHead', 'img/trainHead3.png');} function create() { var globalY = game.world.height / 3; trainUnitHeight = h / 8; trainUnitWidth = w / 5; // Train head trainHead = game.add.sprite(game.world.width, globalY, 'trainHead'); trainHead.anchor.setTo(0.5); SetDimensions(trainHead, trainUnitWidth, trainUnitHeight); game.physics.arcade.enable(trainHead); trainHead.body.velocity.x = speed;} function update() {} function SetDimensions(sprite, width, height) { sprite.width = width; sprite.height = height;} Any help/suggestions are greatly appreciated! Thanks!!repro.zip Link to comment Share on other sites More sharing options...
MikeMike Posted May 12, 2015 Share Posted May 12, 2015 I'm facing the same issue, I'm surprise Phaser has such poor performance even for very simple games!! Link to comment Share on other sites More sharing options...
Hsaka Posted May 13, 2015 Share Posted May 13, 2015 Hi, try using the latest version of Phaser and including the following line in preload:game.forceSingleUpdate = true;I've attached a version of your example which works smoothly for me. It uses Phaser 2.3repro.zip Link to comment Share on other sites More sharing options...
Recommended Posts