Phaser: Uncaught TypeError: Cannot read property 'getIndex' of null at Text.getIndexList

Created on 6 Jan 2021  ·  7Comments  ·  Source: photonstorm/phaser

Version

Phaser Version:3.51.0
Operating system:Mac Pro
Browser:Version 87.0.4280.88 (Official Build) (x86_64)

Description

Phaser3

phaser.js:3680 Uncaught TypeError: Cannot read property 'getIndex' of null
    at Sprite.getIndexList (phaser.js:3680)
    at InputPlugin.sortHandlerGO (phaser.js:184065)
    at Array.sort (<anonymous>)
    at InputPlugin.sortGameObjects (phaser.js:184023)
    at InputPlugin.update (phaser.js:182073)
    at InputManager.updateInputPlugins (phaser.js:91398)
    at InputManager.onMouseMove (phaser.js:91606)
    at HTMLCanvasElement.onMouseMove (phaser.js:92768)

It only happens in my project when call text.setInteractive, but I can’t reproduce it in https://labs.phaser.io/edit.html

Example Test Code

var text = this.add.text(100, 100, 'Phaser');
text.setInteractive().on('pointerdown', () => {
console.log('hello world');
});

Additional Information

⌨️ Input 🤷‍♂️ More info needed

Most helpful comment

Thank you for submitting this issue. We have fixed this and the fix has been pushed to the master branch. It will be part of the next release. If you get time to build and test it for yourself we would appreciate that.

All 7 comments

Does this example work for you? http://labs.phaser.io/view.html?src=src/animation/aseprite%20animation.js

As it uses Text objects down the left, all of which are interactive.

I've been looking at this for a while this morning, but I can't replicate it with something as simple as your example test code. So it has to be something else. Maybe Scene restart related? But if you try your test code in isolation, I'm confident it'll work fine. There's something outside of it triggering this.

Digging more into this today, created this test: http://labs.phaser.io/view.html?src=src/bugs/5489%20container%20input.js

Still can't trigger it. There must be something else being overlooked. A Scene restart maybe? Layer?

Hi! I've encountered the same problem. Still digging it, but I think this might have something to do with objects being interactive and overlapping.
I have a tab which retracts itself from the top menu. While hidden, buttons "above" it are throwing this error. I will try to reproduce it and give an example.

EDIT:
Working for Phaser. 3.50.0

https://jsfiddle.net/gkyor893/

Interactive object inside container which is below another object outside of this container is causing it.
Remove .setInteractive from square to make it work.

Yeah, I narrowed it down to objects inside Containers AND having another outside of it (not of the same type), because the internal one has a null displayList property. Looking at a way to fix it now, but will update this issue when it's closed.

Thank you for submitting this issue. We have fixed this and the fix has been pushed to the master branch. It will be part of the next release. If you get time to build and test it for yourself we would appreciate that.

I happen to have this exact problem. I updated Phaser to 3.52.0. Problem went away right away.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rootasjey picture rootasjey  ·  3Comments

cncolder picture cncolder  ·  4Comments

halilcakar picture halilcakar  ·  4Comments

rexrainbow picture rexrainbow  ·  4Comments

Colbydude picture Colbydude  ·  4Comments