Skip to content

Commit 507bb6a

Browse files
committed
Added customHitArea boolean property
1 parent 53c14df commit 507bb6a

3 files changed

Lines changed: 5 additions & 0 deletions

File tree

src/input/CreateInteractiveObject.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ var CreateInteractiveObject = function (gameObject, hitArea, hitAreaCallback)
3838
hitArea: hitArea,
3939
hitAreaCallback: hitAreaCallback,
4040

41+
// Has the dev specified their own shape, or is this bound to the texture size?
42+
customHitArea: false,
43+
4144
localX: 0,
4245
localY: 0,
4346

src/input/InputPlugin.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1764,6 +1764,7 @@ var InputPlugin = new Class({
17641764

17651765
var io = (!gameObject.input) ? CreateInteractiveObject(gameObject, shape, callback) : gameObject.input;
17661766

1767+
io.customHitArea = true;
17671768
io.dropZone = dropZone;
17681769
io.cursor = (useHandCursor) ? 'pointer' : cursor;
17691770

src/input/typedefs/InteractiveObject.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
* @property {Phaser.Cameras.Scene2D.Camera} camera - The most recent Camera to be tested against this Interactive Object.
1212
* @property {any} hitArea - The hit area for this Interactive Object. Typically a geometry shape, like a Rectangle or Circle.
1313
* @property {Phaser.Input.Types.HitAreaCallback} hitAreaCallback - The 'contains' check callback that the hit area shape will use for all hit tests.
14+
* @property {boolean} customHitArea - Was the hitArea for this Interactive Object created based on texture size (false), or a custom shape? (true)
1415
* @property {number} localX - The x coordinate that the Pointer interacted with this object on, relative to the Game Object's top-left position.
1516
* @property {number} localY - The y coordinate that the Pointer interacted with this object on, relative to the Game Object's top-left position.
1617
* @property {(0|1|2)} dragState - The current drag state of this Interactive Object. 0 = Not being dragged, 1 = being checked for drag, or 2 = being actively dragged.

0 commit comments

Comments
 (0)