Skip to content

Commit ef2b8d6

Browse files
committed
setInteractive now works on non-zero sized Containers. Sorting fixed.
1 parent 32818ee commit ef2b8d6

2 files changed

Lines changed: 19 additions & 8 deletions

File tree

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,12 @@
66

77
### Updates
88

9+
* Container.setInteractive can now be called without any arguments as long as you have called Container.setSize first (thanks rex)
10+
911
### Bug Fixes
1012

1113
* PluginManager.destroy didn't reference the plugin correctly, throwing an Uncaught TypeError if you tried to destroy a game instance. Fix #3668 (thanks @Telokis)
14+
* If a Container and its child were both input enabled they will now be sorted correctly in the InputPlugin (thanks rex)
1215

1316
### Examples, Documentation and TypeScript
1417

src/input/InputPlugin.js

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1196,12 +1196,6 @@ var InputPlugin = new Class({
11961196
{
11971197
var gameObject = gameObjects[i];
11981198

1199-
if (gameObject.type === 'Container')
1200-
{
1201-
console.warn('Container.setInteractive() must specify a Shape');
1202-
continue;
1203-
}
1204-
12051199
var frame = gameObject.frame;
12061200

12071201
var width = 0;
@@ -1218,6 +1212,12 @@ var InputPlugin = new Class({
12181212
height = gameObject.height;
12191213
}
12201214

1215+
if (gameObject.type === 'Container' && (width === 0 || height === 0))
1216+
{
1217+
console.warn('Container.setInteractive() must specify a Shape or call setSize() first');
1218+
continue;
1219+
}
1220+
12211221
if (width !== 0 && height !== 0)
12221222
{
12231223
gameObject.input = CreateInteractiveObject(gameObject, new Rectangle(0, 0, width, height), callback);
@@ -1410,6 +1410,16 @@ var InputPlugin = new Class({
14101410
// Quick bail out when both children have the same container
14111411
return childB.parentContainer.getIndex(childB) - childA.parentContainer.getIndex(childA);
14121412
}
1413+
else if (childA.parentContainer === childB)
1414+
{
1415+
// Quick bail out when childA is a child of childB
1416+
return -1;
1417+
}
1418+
else if (childB.parentContainer === childA)
1419+
{
1420+
// Quick bail out when childA is a child of childB
1421+
return 1;
1422+
}
14131423
else
14141424
{
14151425
// Container index check
@@ -1419,8 +1429,6 @@ var InputPlugin = new Class({
14191429

14201430
for (var i = 0; i < len; i++)
14211431
{
1422-
// var indexA = listA[i][0];
1423-
// var indexB = listB[i][0];
14241432
var indexA = listA[i];
14251433
var indexB = listB[i];
14261434

0 commit comments

Comments
 (0)