Problem with texture buttons?

so I’m trying to finish off my button menu system which is here :

https://thundros.github.io/menu-system-doosan/

& for some reason even though 'this.button' is a sprite, I’m still getting the error : 'Uncaught TypeError : Cannot read property 'pointerdown' of undefined' in the code :

https://thundros.github.io/menu-system-doosan/src/Scenes/TitleScene.js

Line{s} : '221-236'

The button is created with this class :

https://thundros.github.io/menu-system-doosan/src/Objects/Button.js

As you can see, the 'CreateButton ( )' function returns 'this.button' which is a sprite, which should work with : '.on ( )'

basically, when clicking the pointer down on the button, it should fade out all the buttons at once with different fade values until fully transparent. after, it should switch scenes to whichever button gets clicked on.

Any help like always is GREATLY appreciated!

someone can help?

getting tired of being ignored… :frowning:

Are you stepping through your code?

I didn’t get that error, I got a different one, for the line

this.cameras.main.centerOn ( 0, 0 );

because this.cameras is undefined.

Button.js is a little mixed up. It’s extending Container but it’s calling Scene from its constructor.

The reason you’re not getting a lot of responses is that these are rather ordinary code issues in a complex project. So the answer is just you have to debug your code.

When you get a TypeError, turn on break on error, rerun the code until it breaks, look at the line, find the bad value, and find where it came from.

1 Like