andreyko Posted June 8, 2016 Share Posted June 8, 2016 Hi guys, In one of the methods of game object class I have following code which executed on object click: var tween1 = game.add.tween(this.sprite.scale).to({x: 0}, 100, Phaser.Easing.Elastic.Linear); var tween2 = game.add.tween(this.sprite.scale).to({x: 1}, 100, Phaser.Easing.Elastic.Linear); var tween3 = game.add.tween(this.shadow.scale).to({x: 0}, 100, Phaser.Easing.Elastic.Linear); var tween4 = game.add.tween(this.shadow.scale).to({x: 1}, 100, Phaser.Easing.Elastic.Linear); tween1.chain(tween2); tween3.chain(tween4); tween1.onComplete.add(function() { me.sprite.loadTexture('fruit-' + me.index); }); tween4.onComplete.add(function() { me.closed = false; me.level.onOpenBoxAnimEnd.dispatch(me); }); tween1.start(); tween3.start(); When having 4 of these object in the scene it performs nice, but 30 objects cause performance to be very low (notice that only one object is animated, not all 4 or 30). So maybe I'm doing smth generally wrong? Tested on 8-cores 1.7 HHz CPU. Link to comment Share on other sites More sharing options...
WombatTurkey Posted June 8, 2016 Share Posted June 8, 2016 I don't really see anything out of the ordinary..check game.tweens._tweens to make sure there is no leakage all I can think of.. srry Link to comment Share on other sites More sharing options...
andreyko Posted June 8, 2016 Author Share Posted June 8, 2016 3 hours ago, WombatTurkey said: I don't really see anything out of the ordinary..check game.tweens._tweens to make sure there is no leakage all I can think of.. srry Thanks man, checked it, have only 2 tweens running simultaneously.. Link to comment Share on other sites More sharing options...
drhayes Posted June 8, 2016 Share Posted June 8, 2016 How are these tweens created? How do you know you only have 2 running simultaneously? Are you calling Phaser.TweenManager.getAll and counting what it hands back to you? Link to comment Share on other sites More sharing options...
andreyko Posted June 9, 2016 Author Share Posted June 9, 2016 10 hours ago, drhayes said: How are these tweens created? How do you know you only have 2 running simultaneously? Are you calling Phaser.TweenManager.getAll and counting what it hands back to you? They are created in first 4 lines of code snippet var tween1 = game.add.tween(this.sprite.scale).to({x: 0}, 100, Phaser.Easing.Elastic.Linear); var tween2 = game.add.tween(this.sprite.scale).to({x: 1}, 100, Phaser.Easing.Elastic.Linear); var tween3 = game.add.tween(this.shadow.scale).to({x: 0}, 100, Phaser.Easing.Elastic.Linear); var tween4 = game.add.tween(this.shadow.scale).to({x: 1}, 100, Phaser.Easing.Elastic.Linear); Yes, I'm calling Phaser.TweenManager.getAll(), it's the same as checking game.tweens._tweens Link to comment Share on other sites More sharing options...
drhayes Posted June 10, 2016 Share Posted June 10, 2016 I was wondering if the tweens are hanging around, or if you're creating way more than you thought -- those both might explain any performance problems. I'm kinda stumped and don't have a lot of experience optimizing for mobile unfortunately. Link to comment Share on other sites More sharing options...
andreyko Posted June 13, 2016 Author Share Posted June 13, 2016 Seems like the problem is caused by Cordova Webview, cause when running web version of the game on the mobile animation is perfect. Link to comment Share on other sites More sharing options...
icp Posted June 13, 2016 Share Posted June 13, 2016 Try Crosswalk + Cordova. Link to comment Share on other sites More sharing options...
andreyko Posted June 14, 2016 Author Share Posted June 14, 2016 16 hours ago, icp said: Try Crosswalk + Cordova. Also thought about this With Crosswalk works perfect, but it is +25MB(!) to app size... Link to comment Share on other sites More sharing options...
in mono Posted June 15, 2016 Share Posted June 15, 2016 Maybe it's loading textures that causes slowdowns, not tweens. It's said in the documentation that it is an expensive thing to do. As for file sizes of different ways of packing the game for mobile - the size difference might be because in one case it's the device's WebView implementation that's used, in other cases - WebView is packed along with the game (ensuring that the same one will be used across different devices). Can't tell by heart which is which, but that must be it. Link to comment Share on other sites More sharing options...
Recommended Posts