ArcadePhysics.Body.phase is checked in postUpdate to prevent it from being called multiple times in a single frame.

This commit is contained in:
photonstorm 2014-04-15 02:50:25 +01:00
parent 1164bf85ac
commit 3b73c17997
2 changed files with 10 additions and 3 deletions

View file

@ -45,9 +45,9 @@ Happy coding everyone! See you on the forums.
We have a new [Getting Started Guide](http://phaser.io/getting-started-js.php) which covers all you need to begin developing games with Phaser. From setting up a web server to picking an IDE. If you're new to HTML5 game development, or are coming from another language like AS3, then we recommend starting there. We have a new [Getting Started Guide](http://phaser.io/getting-started-js.php) which covers all you need to begin developing games with Phaser. From setting up a web server to picking an IDE. If you're new to HTML5 game development, or are coming from another language like AS3, then we recommend starting there.
There is a comprehensive [How to Learn Phaser](http://gamedevelopment.tutsplus.com/articles/how-to-learn-the-phaser-html5-game-engine--gamedev-13643) guide on the GameDevTuts+ site which is a great place to learn where to find tutorials, examples and support. We wrote a comprehensive [How to Learn Phaser](http://gamedevelopment.tutsplus.com/articles/how-to-learn-the-phaser-html5-game-engine--gamedev-13643) guide for GameDevTuts+ which covers finding tutorials, examples and support.
There is also an [un-official Getting Started Guide](http://www.antonoffplus.com/coding-an-html5-game-for-30-minutes-or-an-introduction-to-the-phaser-framework). Finally the growing list of [community authored Phaser Tutorials](http://www.lessmilk.com/phaser-tutorial/) is growing fast!
![Phaser Logo](http://www.photonstorm.com/wp-content/uploads/2013/09/phaser_10_release.jpg) ![Phaser Logo](http://www.photonstorm.com/wp-content/uploads/2013/09/phaser_10_release.jpg)
@ -64,6 +64,7 @@ Version 2.0.4 - "Mos Shirare" - in development
* The Input.reset `hard` reset parameter is now passed down to the Keyboard and Key reset methods. * The Input.reset `hard` reset parameter is now passed down to the Keyboard and Key reset methods.
* AnimationManager.destroy now iterates through child animations calling destroy on all of them, avoiding a memory leak (thanks stauzs) * AnimationManager.destroy now iterates through child animations calling destroy on all of them, avoiding a memory leak (thanks stauzs)
* AnimationManager.play will now call Animation.stop on the current animation before switching to the new one (thanks @nihakue, #713) * AnimationManager.play will now call Animation.stop on the current animation before switching to the new one (thanks @nihakue, #713)
* ArcadePhysics.Body.phase is checked in postUpdate to prevent it from being called multiple times in a single frame.
### New Features ### New Features

View file

@ -287,7 +287,7 @@ Phaser.Physics.Arcade.Body = function (sprite) {
this.tilePadding = new Phaser.Point(); this.tilePadding = new Phaser.Point();
/** /**
* @property {number} phaser - Is this Body in a preUpdate or postUpdate state? * @property {number} phaser - Is this Body in a preUpdate (1) or postUpdate (2) state?
*/ */
this.phase = 0; this.phase = 0;
@ -434,6 +434,12 @@ Phaser.Physics.Arcade.Body.prototype = {
*/ */
postUpdate: function () { postUpdate: function () {
// Only allow postUpdate to be called once per frame
if (this.phase === 2)
{
return;
}
this.phase = 2; this.phase = 2;
if (this.deltaX() < 0) if (this.deltaX() < 0)