MoreK Posted October 12, 2015 Share Posted October 12, 2015 iPad2 (& Safari) seem to drop my game's frame rate from 60ps to 30fps max. 30fps is still ok, so I tried to resolve the move/speed issue by using delta time between frames, at the beginning of every update routine: var deltaTime = game.time.elapsed; ...and applying deltaTime to x/y movements. This just caused image & sprite movements to double their speed in iPad. Game tweens seemed to suffer the same problem. However P2 physics seem to work ok in all devices. After searching and testing, I found a solution for delta time: var deltaTime = game.time.physicsElapsed; And for tweens, setting this parameter did the trick: Tween.frameBased = true; ...although duration seem to be still in milliseconds, not in frames, as the documentation states. I'm wondering where Phaser.Time.elapsed is needed, when Phaser.Time.physicsElapsed does the trick so much better?! Link to comment Share on other sites More sharing options...
Skeptron Posted October 13, 2015 Share Posted October 13, 2015 You shouldn't have to do this yourself, Phaser is already built to use deltaT. So your objects will move at the same speed, regardless of the FPS. What version of Phaser are you using? This has been implemented quite a while ago... Link to comment Share on other sites More sharing options...
MoreK Posted October 13, 2015 Author Share Posted October 13, 2015 You shouldn't have to do this yourself, Phaser is already built to use deltaT. So your objects will move at the same speed, regardless of the FPS. What version of Phaser are you using? This has been implemented quite a while ago... Wow, I've been hasty, reading older comment and recommendations. You are absolutely right. I took away my delta time logic and image/sprite movement works as expected no matter FPS. However, I still see the issue in a chained tween. It shows 3-2-1-GO countdown at the beginning of the game, using PNG images. Other tweens in the game seem to work ok, but this one runs double speed in 30fps. "frameBased" parameter seem to fix the issue, so not a big deal, but clearly something I don't understand. Or maybe a bug? Here's the code: this.ctp_twA = this.add.tween(this.ctp_3).to({alpha: 1, width: 206, height: 132}, 1000, Phaser.Easing.Linear.None); //this.ctp_twA.frameBased = true; this.ctp_twA.onComplete.add(this.removeImg, this, this.ctp_3); this.ctp_twB = this.add.tween(this.ctp_2).to({alpha: 1, width: 206, height: 132}, 1000, Phaser.Easing.Linear.None); //this.ctp_twB.frameBased = true; this.ctp_twB.onComplete.add(this.removeImg, this, this.ctp_2); this.ctp_twC = this.add.tween(this.ctp_1).to({alpha: 1, width: 206, height: 132}, 1000, Phaser.Easing.Linear.None); //this.ctp_twC.frameBased = true; this.ctp_twC.onComplete.add(this.removeImgAndGo, this, this.ctp_1); this.ctp_twGO = this.add.tween(this.ctp_go).to({alpha: 1, width: 206, height: 132}, 1000, Phaser.Easing.Linear.None); //this.ctp_twGO.frameBased = true; this.ctp_twGO.onComplete.add(this.removeImg, this, this.ctp_go); this.ctp_twA.chain(this.ctp_twB, this.ctp_twC, this.ctp_twGO); this.ctp_twA.start(); Link to comment Share on other sites More sharing options...
Skeptron Posted October 13, 2015 Share Posted October 13, 2015 Hmmm there was indeed an issue with tweens (I remember at least a post dealing with this)... But I think what you are doing is fine. If you want the tween to play at the same speed whatever the FPS, you should set frameBased = false. You could check what the default value is (false would make sense, but I'm not sure). Link to comment Share on other sites More sharing options...
MoreK Posted October 13, 2015 Author Share Posted October 13, 2015 For frameBased the default value is 'false'. To make it work in 30fps I need to set it 'true'. Which sounds odd, but it fixes the problem. If I have time I'l test it more... Thanks! Link to comment Share on other sites More sharing options...
Recommended Posts