diff --git a/README.md b/README.md index e40ab8296..bc80723c5 100644 --- a/README.md +++ b/README.md @@ -87,7 +87,7 @@ New features: * Added a new Project Template "Full Screen Mobile" which you can find in the resources folder. Contains html / css / layout needed for a deployed Phaser game. * Body.speed - the current speed of the body. * Body.friction - This now replaces Body.drag and provides for a much smoother friction experience. -* Body.sleeping - A Physics Body can now be set to 'go to sleep' if the velocity drops between the given range (sleepMin and sleepMax) for the given period of sleepDuration (see the new examples). +* Body.minBounceVelocity - If a Body has bounce set, this threshold controls if it should rebound or not. Use it to stop 'jittering' on bounds/tiles with super-low velocities. * QuadTree.populate - you can pass it a Group and it'll automatically insert all of the children ready for inspection. @@ -149,6 +149,7 @@ Updates: * Body.acceleration is now much smoother and less eratic at high speeds. * Removed ArcadePhysics binding to the QuadTree, so it can now be used independantly of the physics system. * Removed ArcadePhysics.preUpdate and postUpdate as neither are needed any more. +* Body.bottom and Body.right are no longer rounded, so will give accurate sub-pixel values. Bug Fixes: @@ -173,6 +174,7 @@ Bug Fixes: * Sounds will now loop correctly if they are paused and resumed (thanks haden) * InputHandler.checkBoundsRect and checkBoundsSprite now take into account if the Sprite is fixedToCamera or not. * Removed the frame property from TileSprites as it cannot use them, it tiles the whole image only, not just a section of it. +* Fixed WebGLRenderer updateGraphics bug (thanks theadam) You can view the Change Log for all previous versions at https://github.com/photonstorm/phaser/changelog.md diff --git a/examples/wip/blocked.js b/examples/wip/blocked.js index 9dd3653fa..190807882 100644 --- a/examples/wip/blocked.js +++ b/examples/wip/blocked.js @@ -25,25 +25,47 @@ function create() { var bg = game.add.sprite(0, 0, bmd); bg.body.moves = false; - test8(); + test9(); + +} + +// stacked +function test9() { + + game.physics.gravity.y = 500; + + sprite = game.add.sprite(400, 100, 'ball'); + sprite.body.collideWorldBounds = true; + sprite.body.bounce.setTo(0.8, 0.8); + sprite.body.minBounceVelocity = 0.8; + + sprite2 = game.add.sprite(400, 300, 'ball'); + sprite2.body.collideWorldBounds = true; + sprite2.body.bounce.setTo(0.5, 0.5); + sprite2.body.minBounceVelocity = 0.8; + + // game.input.onDown.add(launch8, this); } // gravity into floor jiggle function test8() { - game.physics.gravity.y = 150; + game.physics.gravity.y = 1000; sprite = game.add.sprite(400, 100, 'ball'); sprite.body.collideWorldBounds = true; + // it's all about tweaking these values sprite.body.bounce.setTo(0.8, 0.8); - sprite.body.minBounceVelocity = 0.8; + sprite.body.minBounceVelocity = 1.2; sprite.body.velocity.x = -400; + sprite.body.friction = 1.2; sprite2 = game.add.sprite(500, 100, 'ball'); sprite2.body.collideWorldBounds = true; sprite2.body.bounce.setTo(0.5, 0.5); sprite2.body.minBounceVelocity = 0.8; + sprite2.body.friction = 0.5; game.input.onDown.add(launch8, this); diff --git a/src/physics/arcade/Body.js b/src/physics/arcade/Body.js index 54d303f67..f4a8849b5 100644 --- a/src/physics/arcade/Body.js +++ b/src/physics/arcade/Body.js @@ -119,11 +119,6 @@ Phaser.Physics.Arcade.Body = function (sprite) { */ this.velocity = new Phaser.Point(); - /** - * @property {Phaser.Point} prevVelocity - The velocity in pixels per second sq. of the Body. - */ - this.prevVelocity = new Phaser.Point(); - /** * @property {Phaser.Point} acceleration - The velocity in pixels per second sq. of the Body. */ @@ -380,12 +375,6 @@ Phaser.Physics.Arcade.Body.prototype = { this.preY = (this.sprite.world.y - (this.sprite.anchor.y * this.height)) + this.offset.y; this.preRotation = this.sprite.angle; - // if (this.canSleep && this.sleeping && (this.velocity.equals(this.prevVelocity) === false || this.acceleration.isZero() === false)) - // { - // this.sleeping = false; - // this._sleepTimer = 0; - // } - this.x = this.preX; this.y = this.preY; this.rotation = this.preRotation; @@ -407,41 +396,11 @@ Phaser.Physics.Arcade.Body.prototype = { this.checkWorldBounds(); } - // Apply world gravity, acceleration + rotation this.game.physics.updateMotion(this); this.applyMotion(); - - // if (this.canSleep) - // { - // if (!this.sleeping) - // { - // if (this.velocity.x >= this.sleepMin.x && this.velocity.x <= this.sleepMax.x && this.velocity.y >= this.sleepMin.y && this.velocity.y <= this.sleepMax.y) - // { - // if (this._sleepTimer >= this.sleepDuration) - // { - // this.sleeping = true; - // } - // else - // { - // this._sleepTimer += this.game.time.elapsed; - // this.applyMotion(); - // } - // } - // else - // { - // this.applyMotion(); - // } - // } - // } - // else - // { - // this.applyMotion(); - // } } - this.prevVelocity.copyFrom(this.velocity); - }, /** @@ -788,7 +747,6 @@ Object.defineProperty(Phaser.Physics.Arcade.Body.prototype, "bottom", { * @return {number} */ get: function () { - // return Math.floor(this.y + this.height); return this.y + this.height; }, @@ -825,7 +783,6 @@ Object.defineProperty(Phaser.Physics.Arcade.Body.prototype, "right", { * @return {number} */ get: function () { - // return Math.floor(this.x + this.width); return this.x + this.width; }, diff --git a/src/utils/Debug.js b/src/utils/Debug.js index 303d4a652..c49505724 100644 --- a/src/utils/Debug.js +++ b/src/utils/Debug.js @@ -463,9 +463,6 @@ Phaser.Utils.Debug.prototype = { this.splitline('velocity x: ' + sprite.body.velocity.x.toFixed(2), 'y: ' + sprite.body.velocity.y.toFixed(2), 'deltaX: ' + sprite.body.deltaX().toFixed(2), 'deltaY: ' + sprite.body.deltaY().toFixed(2)); this.splitline('motion x: ' + sprite.body.motionVelocity.x.toFixed(2), 'y: ' + sprite.body.motionVelocity.y.toFixed(2)); this.splitline('bounce x: ' + sprite.body.bounce.x.toFixed(2), 'y: ' + sprite.body.bounce.y.toFixed(2)); - // this.splitline('sleeping: ' + sprite.body.sleeping, 'sleepTimer: ' + sprite.body._sleepTimer.toFixed(2)); - // this.splitline('sleepMin x: ' + sprite.body.sleepMin.x, 'y: ' + sprite.body.sleepMin.y); - // this.splitline('sleepMax x: ' + sprite.body.sleepMax.x, 'y: ' + sprite.body.sleepMax.y); this.stop(); },