Skip to content

Commit

Permalink
World.wrap when using the bounds of the object wouldn't adjust the bo…
Browse files Browse the repository at this point in the history
…unds correctly, meaning wrapping outside the camera failed (thanks @jackrugile phaserjs#1020)
  • Loading branch information
photonstorm committed Jul 15, 2014
1 parent f77b4d4 commit 5384251
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 25 deletions.
19 changes: 8 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ Version 2.0.7 - "Amadicia" - -in development-
* TypeScript definitions fixes and updates (thanks @clark-stevenson and @alvinsight)
* GameObjectFactory.spriteBatch now lets you specify `null` as a parameter for the parent and automatically adds the batch to `game.world` as a result. Also fixed jsdocs issues (@petarov #1000)
* Rebuilt the way items are polled for Pointer events (drag, click, move). Now faster and more efficient, especially when some items in the stack require pixel perfect checks.
* InputHandler.checkPointerOver now has a new `fastTest` parameter that forces a skips a pixel perfect check even if enabled.
* InputHandler.checkPointerDown now has a new `fastTest` parameter that forces a skips a pixel perfect check even if enabled.

### New Features

Expand All @@ -66,18 +68,9 @@ Version 2.0.7 - "Amadicia" - -in development-
* Added missing Loader.onPackComplete Signal (thanks @mjeffery #1007)
* QuadTree leveling - Rather than level++ which changes the current nodes level, the subnodes should get the current nodes level+1 (thanks @devinb83 #1018)
* Prevented objects with pixel perfect checks from over-riding other higher priority ID items (#983)
* Group.create was not creating with p2 debug flag (thanks @Dumtard #1014)
* World.wrap when using the bounds of the object wouldn't adjust the bounds correctly, meaning wrapping outside the camera failed (thanks @jackrugile #1020)

### TODO

Adjust how Pointers and Interactive Objects work. Allow an IO to be flagged as "on click only", so it doesn't ever get processed during normal Pointer move events (unless being dragged)

Allow multiple drag items - no longer bind just 1 to a Pointer

Sweep and Prune objects to filter priority IDs.

Allow Groups to have Priority IDs too and input disable entire Groups and all children (let it flow down the chain)

Allow Groups to be InputEnabled? Dragging a Group would be really useful.



Expand Down Expand Up @@ -256,6 +249,10 @@ Here are some of the features planned for future releases:

### Version 2.2 ("Tarabon")

* Adjust how Pointers and Interactive Objects work. Allow an IO to be flagged as "on click only", so it doesn't ever get processed during normal Pointer move events (unless being dragged)
* Allow multiple drag items - no longer bind just 1 to a Pointer
* Allow Groups to have Priority IDs too and input disable entire Groups and all children (let it flow down the chain)
* Allow Groups to be InputEnabled? Dragging a Group would be really useful.
* Scene Manager - json scene parser.
* Comprehensive testing across Firefox OS devices, CocoonJS and Ejecta.
* Ability to control DOM elements from the core game and layer them into the game.
Expand Down
30 changes: 18 additions & 12 deletions src/core/World.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,22 +146,28 @@ Phaser.World.prototype.wrap = function (sprite, padding, useBounds, horizontal,
{
sprite.getBounds();

if (horizontal && sprite._currentBounds.right < this.bounds.x)
if (horizontal)
{
sprite.x = this.bounds.right;
}
else if (horizontal && sprite._currentBounds.x > this.bounds.right)
{
sprite.x = this.bounds.left;
if ((sprite.x + sprite._currentBounds.width) < this.bounds.x)
{
sprite.x = this.bounds.right;
}
else if (sprite.x > this.bounds.right)
{
sprite.x = this.bounds.left;
}
}

if (vertical && sprite._currentBounds.bottom < this.bounds.top)
{
sprite.y = this.bounds.bottom;
}
else if (vertical && sprite._currentBounds.top > this.bounds.bottom)
if (vertical)
{
sprite.y = this.bounds.top;
if ((sprite.y + sprite._currentBounds.height) < this.bounds.top)
{
sprite.y = this.bounds.bottom;
}
else if (sprite.y > this.bounds.bottom)
{
sprite.y = this.bounds.top;
}
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/input/Pointer.js
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ Phaser.Pointer.prototype = {
// Flag it as checked so we don't re-scan it on the next phase
currentNode.checked = true;

if ((!fromClick && currentNode.checkPointerOver(this, true)) || (fromClick && currentNode.checkPointerDown(this, true)))
if ((fromClick && currentNode.checkPointerDown(this, true)) || (!fromClick && currentNode.checkPointerOver(this, true)))
{
this._highestRenderOrderID = currentNode.sprite._cache[3]; // renderOrderID
this._highestInputPriorityID = currentNode.priorityID;
Expand All @@ -492,7 +492,7 @@ Phaser.Pointer.prototype = {
{
if (currentNode && !currentNode.checked && currentNode.validForInput(this._highestInputPriorityID, this._highestRenderOrderID, true))
{
if ((!fromClick && currentNode.checkPointerOver(this, false)) || (fromClick && currentNode.checkPointerDown(this, false)))
if ((fromClick && currentNode.checkPointerDown(this, false)) || (!fromClick && currentNode.checkPointerOver(this, false)))
{
this._highestRenderOrderID = currentNode.sprite._cache[3]; // renderOrderID
this._highestInputPriorityID = currentNode.priorityID;
Expand Down

0 comments on commit 5384251

Please sign in to comment.