Jump to content

Phaser on Android, runs really slow (Cordova / Phone Gap)


koobazaur
 Share

Recommended Posts

Heya,

 

So I just did a little test APP using one of the samples that just tweens a single sprite. And it runs at 4 fps :| Is this normal? Am I doing something wrong? 

 

I have tried both PhoneGap and Cordova. Here's the code:

 


var game = new Phaser.Game(800, 600, Phaser.AUTO, 'phaser-example', { preload: preload, create: create, update: update});
var theText;
var sprite;

function preload() {

    game.load.image('disk', 'assets/sprites/copy-that-floppy.png');
	game.time.advancedTiming = true;
}


function create() {

    sprite = game.add.sprite(400, 100, 'disk');

    game.add.tween(sprite).to( { angle: 45 }, 2000, Phaser.Easing.Linear.None, true);
    game.add.tween(sprite.scale).to( { x: 2, y: 2 }, 2000, Phaser.Easing.Linear.None, true);
    
	theText = game.add.text(game.world.centerX, game.world.centerY, "FPS: ", {
        font: "65px Arial",
        fill: "#ff0044",
        align: "center"
    });

    theText.anchor.setTo(0.5, 0.5);
	
	
}

function update()
{
	 game.debug.text(game.time.fps || '--', 2, 14, "#00ff00");   
	 theText.setText("Time " + game.time.time + "\nFPS " + game.time.fps);
}

 

Link to comment
Share on other sites

Hi, slightly different but relevant... a few months ago I ran heavy load app with babylon in Ionic and it did ok.

Performance information is hard to come by in this area. Ionic seemed like a nice angular extension of PhoneGap, but -> heavy.

So good question - I'd like to know more.

Link to comment
Share on other sites

I haven't tried Crosswalk. If it uses Cordova, is there a reason why I should try it in lieu of Cordova directly?

I ran the test APK on actual phone and it did much better. But one of my other simpler games still ran pretty choppy :/ 

 

I tried my latest and I just get black screen, not even loading. Is there a way to view the console log? Tried going to sdk/platform-tools and calling:

adb logcat browser:V *:S

But it didn't show a single console log line :/

Link to comment
Share on other sites

Cordova uses your default Webview (the default factory browser you have installed in your phone), Crosswalk is a custom webview which has many features like WebGL which will boost your performance. If you would like to debug you can use Android Studio. Import your project from cordovaProject/platforms/android (it should have the .gradle files). Hit build than run your game on emulator or using a real device with ADB (Android Debug Bridge) enabled. You should now see the logcat tab from Android Studio and check if there's any text.

Link to comment
Share on other sites

Hi, I am pretty sure, that "game.debug.text" will be first thing, that will slow your game down a lot. Second thing may be using non-sprite font for text.

I also believe, that your game (example) runs very slowly even if not wrapped with Cordova (if run directly in mobile browser).

From my experience also calling console.log often slows game a lot, so be sure to comment out these outputs in production code.

Link to comment
Share on other sites

Phaser + Cordova have better performance with low resolution. But the performance is bad. Not for platformers. 

PIXI + Cordova with high resolution has better performance. And it has better performance with big resolution of the game (wtf? ) But you need to write from scratch many good things that Phaser offers. 

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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