actes Posted May 23, 2016 Share Posted May 23, 2016 Hello, I've tried to code a FlappyBird-clone in phaser but i have performance issues on mobile devices. When I run the game everything works fine but when the player falls (because of the gravity), it doesn't seem "smooth" anymore and the game lags. I've run the game on a LG G3 and a Sony Xperia Z. thanks in advance var game = new Phaser.Game(288, 512, Phaser.WEBGL); var mainState = { preload: function() { game.load.image('flappy' ,'img/flappy.png'); game.load.image('bg' ,'img/bg.png'); game.load.image('btn' ,'img/btn.png'); game.load.image('ground' ,'img/ground.png'); }, create: function() { game.scale.scaleMode = Phaser.ScaleManager.EXACT_FIT; game.scale.pageAlignHorizontally = true; game.scale.pageAlignVertically = true; game.physics.startSystem(Phaser.Physics.ARCADE); this.bg = game.add.sprite(0, 0, 'bg'); this.ground = game.add.sprite(0, game.height - 112, 'ground'); game.physics.arcade.enableBody(this.ground); this.ground.body.immovable = true; this.player = game.add.sprite(game.world.centerX, game.world.centerY, 'flappy'); this.player.anchor.set(0.5); game.physics.arcade.enableBody(this.player); this.player.body.bounce.set(0.2); this.player.body.gravity.y = 500; game.input.onTap.add(this.jump, this); }, update: function() { game.physics.arcade.collide(this.player, this.ground); }, jump: function() { this.player.body.velocity.y = -200; } }; game.state.add('main', mainState); game.state.start('main'); Link to comment Share on other sites More sharing options...
VitaZheltyakov Posted May 23, 2016 Share Posted May 23, 2016 Try: var game = new Phaser.Game(288, 512, Phaser.CANVAS); Link to comment Share on other sites More sharing options...
shohan4556 Posted May 24, 2016 Share Posted May 24, 2016 I have used arcade physics so many times and it works fine for mobile devices. you can try crosswalk to wrap your game its good. Link to comment Share on other sites More sharing options...
rgk Posted May 24, 2016 Share Posted May 24, 2016 Interestingly enough, I now notice on slower devices my game goes in slow-motion. Try the saveCPU plugin. Link to comment Share on other sites More sharing options...
Recommended Posts