Jump to content

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


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 post
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 post
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 post
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 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.

×
×
  • Create New...