Jump to content

Simple game - horrible performance on Android/CooconJS


nookiepl
 Share

Recommended Posts

Hi!

 

I'm trying to develop my first game with Phaser. First of all - great engine. Really easy to understand and well documented. Game is rather simple (i think).

 

- There are around 50 sprites (loaded in "create" function, 1.6 MB PNGs) falling one by one from above (with tween, tried gravity too but it's overkill for such simple animation?).

- There is onInputDown bind and onOutOfBounds one.

- There is text layer with score.

 

On my PC (i7, 8GB RAM, decent GPU) there is no problem with perfomance at all. Problem is when I run it via CocoonJS launcher on my Samsung S4 (I've tried with Chrome too, same or even worse results). Performance of game is rather bad. Sprites are not moving smoothly. It is normal or should I look for error on my side? :P

Link to comment
Share on other sites

graviy is not really an overkill.. keeping your update loop simple is much more important.. i make heavy use of physics in my game and what brings performance down are particle emitters... 50 tweened sprites sound horrible to me.. (depends on how many parallel tweens you run) but tweening 6 sprites in a loop costs me 10 fps already in a new game of mine so i deleted the tweens.. do you reuse those sprites properly?

Link to comment
Share on other sites

CocoonJS show 55-60+ FPS all time, even when animation slows down and is not smoothly.

 

There are only 1-2 parallel sprites. I'm creating them in create function (in object form). And using game.time.events.repeat(Phaser.Timer.SECOND * 2, 100000, dispatchSprite, this); to dispatch sprite (btw. is there way to make repeat infinite?). And here is dispatchSprite function.

sprite = sprites[losowaFigura + '_' + losowyKolor];    sprite.y = -300;    sprite.x = getRandomInt(10, game.width - 300);    sprite.revive();    game.add.tween(sprite).to({ y: 4000 }, 8000, Phaser.Easing.Linear.None, true, 0, 0, false);    // Custom data    sprite.figura = losowaFigura;    sprite.kolor = losowyKolor;    sprite.angle = getRandomInt(-60, 60);

onClick and onOutOfBonds i'm killing sprite. (.kill()).

Link to comment
Share on other sites

It's highly likely the issue is because Phaser is trying to run a 60fps update loop but isn't actually getting 60 fps out of the device. You've two options:

game.time.desiredFps = 30

(or maybe 50, try and see)

 

Or bundle the update / render loop:

game.forceSingleUpdate = true

Be careful with the above though, it basically skips the delta timer in an attempt to blast through one logic update per render update.

Link to comment
Share on other sites

It's highly likely the issue is because Phaser is trying to run a 60fps update loop but isn't actually getting 60 fps out of the device. You've two options:

game.time.desiredFps = 30

(or maybe 50, try and see)

 

Or bundle the update / render loop:

game.forceSingleUpdate = true

Be careful with the above though, it basically skips the delta timer in an attempt to blast through one logic update per render update.

 

game.time.desiredFps didn't make difference at all, but forceSingleUpdate makes animation smooth.

 

Also as no-one else has mentioned it yet - asset dimensions and game resolution play a massive role in speed.

 

So... 

var game = new Phaser.Game('100%', '100%', Phaser.AUTO, '', { preload: preload, create: create, update: update });+<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi" />

is not best idea?

Link to comment
Share on other sites

Good day, I've also been having some problems with my game stuttering using the latest Phaser 2.3.0 and CocoonJS. Using game.forceSingleUpdate = true makes the game run buttery smooth, smoother than I've ever experienced with CocoonJS in fact. I'm just wondering what the ramifications of using this will be? 

Link to comment
Share on other sites

Ok so when you use forceSingleUpdate you basically eliminate the delta timer inside Phaser. This means all physics will be using an 'assumed' dt value of 60fps. If you know your game can reach 60fps under Cocoon without any troubles, then it will be fine. Also if your game doesn't really use much or any Arcade Physics, you will be fine doing this too. P2 has its own physics timer, so it won't touch that.

 

All that is likely to happen is that on really crappy devices that can't manage 60fps then the Arcade Physics calculations will likely be wrong. But like I said above, this might not matter. Depends on the game.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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