Skip to content

Commit d875a59

Browse files
committed
InteractiveObject.alwaysEnabled is a new boolean that allows an interactive Game Object to always receive input events, even if it's invisible or won't render.
1 parent bc5c7cf commit d875a59

4 files changed

Lines changed: 4 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
### New Features
66

77
* `GameConfig.antialiasGL` is a new boolean that allows you to set the `antialias` property of the WebGL context during creation, without impacting any subsequent textures or the canvas CSS.
8+
* `InteractiveObject.alwaysEnabled` is a new boolean that allows an interactive Game Object to always receive input events, even if it's invisible or won't render.
89

910
### Updates
1011

src/input/CreateInteractiveObject.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ var CreateInteractiveObject = function (gameObject, hitArea, hitAreaCallback)
2727
gameObject: gameObject,
2828

2929
enabled: true,
30+
alwaysEnabled: false,
3031
draggable: false,
3132
dropZone: false,
3233
cursor: false,

src/input/InputManager.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -809,7 +809,7 @@ var InputManager = new Class({
809809
{
810810
var input = gameObject.input;
811811

812-
if (!input || !input.enabled || !gameObject.willRender(camera))
812+
if (!input || !input.enabled || (!input.alwaysEnabled && !gameObject.willRender(camera)))
813813
{
814814
return false;
815815
}

src/input/typedefs/InteractiveObject.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
*
55
* @property {Phaser.GameObjects.GameObject} gameObject - The Game Object to which this Interactive Object is bound.
66
* @property {boolean} enabled - Is this Interactive Object currently enabled for input events?
7+
* @property {boolean} alwaysEnabled - An Interactive Object that is 'always enabled' will receive input even if the parent object is invisible or won't render.
78
* @property {boolean} draggable - Is this Interactive Object draggable? Enable with `InputPlugin.setDraggable`.
89
* @property {boolean} dropZone - Is this Interactive Object a drag-targets drop zone? Set when the object is created.
910
* @property {(boolean|string)} cursor - Should this Interactive Object change the cursor (via css) when over? (desktop only)

0 commit comments

Comments
 (0)