Skip to content

Commit 95eb4fc

Browse files
committed
Setting pixelPerfect when input enabling a Container would cause it to crash, because Container's don't have a texture to check. It will now throw a run-time warning and skip the Container for input. You should use a custom input callback instead. Fix phaserjs#4492
1 parent 183ce1b commit 95eb4fc

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ Notes:
178178
* `InputPlugin.clear` has a new argument `skipQueue` which is used to avoid clearing a Game Object twice. This, combined with the fix for 4463 means you will no longer get a `Cannot read property 'dragState'` error if you destroy a Game Object enabled for drag where another draggable object exists. Fix #4228 (thanks @YannCaron)
179179
* `Phaser.Physics.Arcade.Events` is now exposed in the namespace, preventing it from erroring if you use them in TypeScript. Fix #4481 (thanks @danielalves)
180180
* `UpdateList.remove` will now move the removed child to the internal `_pendingRemoval` array, instead of slicing it directly out of the active list. The pending list is cleared at the start of the next game frame. Fix #4365 (thanks @jcyuan)
181+
* Setting `pixelPerfect` when input enabling a Container would cause it to crash, because Containers don't have a texture to check. It will now throw a run-time warning and skip the Container for input. You should use a custom input callback instead. Fix #4492 (thanks @BigZaphod)
181182

182183
### Examples, Documentation and TypeScript
183184

src/input/InputPlugin.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1745,6 +1745,7 @@ var InputPlugin = new Class({
17451745
var dropZone = false;
17461746
var cursor = false;
17471747
var useHandCursor = false;
1748+
var pixelPerfect = false;
17481749

17491750
// Config object?
17501751
if (IsPlainObject(shape))
@@ -1758,7 +1759,7 @@ var InputPlugin = new Class({
17581759
cursor = GetFastValue(config, 'cursor', false);
17591760
useHandCursor = GetFastValue(config, 'useHandCursor', false);
17601761

1761-
var pixelPerfect = GetFastValue(config, 'pixelPerfect', false);
1762+
pixelPerfect = GetFastValue(config, 'pixelPerfect', false);
17621763
var alphaTolerance = GetFastValue(config, 'alphaTolerance', 1);
17631764

17641765
if (pixelPerfect)
@@ -1783,6 +1784,12 @@ var InputPlugin = new Class({
17831784
{
17841785
var gameObject = gameObjects[i];
17851786

1787+
if (pixelPerfect && gameObject.type === 'Container')
1788+
{
1789+
console.warn('Cannot pixelPerfect test a Container. Use a custom callback.');
1790+
continue;
1791+
}
1792+
17861793
var io = (!gameObject.input) ? CreateInteractiveObject(gameObject, shape, callback) : gameObject.input;
17871794

17881795
io.customHitArea = true;

0 commit comments

Comments
 (0)