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 #4492

This commit is contained in:
Richard Davey 2019-04-26 10:56:06 +01:00
parent 183ce1b96c
commit 95eb4fc03d
2 changed files with 9 additions and 1 deletions

View file

@ -178,6 +178,7 @@ Notes:
* `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)
* `Phaser.Physics.Arcade.Events` is now exposed in the namespace, preventing it from erroring if you use them in TypeScript. Fix #4481 (thanks @danielalves)
* `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)
* 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)
### Examples, Documentation and TypeScript

View file

@ -1745,6 +1745,7 @@ var InputPlugin = new Class({
var dropZone = false;
var cursor = false;
var useHandCursor = false;
var pixelPerfect = false;
// Config object?
if (IsPlainObject(shape))
@ -1758,7 +1759,7 @@ var InputPlugin = new Class({
cursor = GetFastValue(config, 'cursor', false);
useHandCursor = GetFastValue(config, 'useHandCursor', false);
var pixelPerfect = GetFastValue(config, 'pixelPerfect', false);
pixelPerfect = GetFastValue(config, 'pixelPerfect', false);
var alphaTolerance = GetFastValue(config, 'alphaTolerance', 1);
if (pixelPerfect)
@ -1783,6 +1784,12 @@ var InputPlugin = new Class({
{
var gameObject = gameObjects[i];
if (pixelPerfect && gameObject.type === 'Container')
{
console.warn('Cannot pixelPerfect test a Container. Use a custom callback.');
continue;
}
var io = (!gameObject.input) ? CreateInteractiveObject(gameObject, shape, callback) : gameObject.input;
io.customHitArea = true;