Jump to content

Phaser "onChildInputDown" for "group" is undefined


loover
 Share

Recommended Posts

Hi. Here is code:

group = game.add.group();
group.inputEnableChildren = true;
....
group .create(...);
...
group.onChildInputDown.add(onMouseDown, this);

Console show an error:

 Uncaught TypeError: Cannot read property 'add' of undefined

E.g. "onChildInputDown" is undefined.

How fix it?

Link to comment
Share on other sites

14 hours ago, rich said:

Well this line is wrong for a start: '    group .create(...);' and needs removing.

And you don't have a function called 'onMouseDown' either, so it can't work until you add that.

I used v 2.2.2. What you mean "and needs removing."? How add to group new sprites?

onMouseDown function exist, just not in there. Again, issue not in this place. Maybe this a version issue.

 

I tried 2.6.2 but get the error when "load.start()":

Phaser.Loader - active loading canceled / reset

 

In both cases I used the official tutorials (http://phaser.io/examples/v2/loader/load-events). In both cases on the pages version set to:

Phaser Version: 2.6.2 - Kore Springs

Link to comment
Share on other sites

i just have updated the pen

so at first if you use group instead of  a named variable it's confusing

group = game.add.group(); //btw (by the way), i can't format like <code></code>

it's better to use a different variale name it means you have to define first what is the keys/assets images you want to manipulate in your game

give me some time for this pen we can discuss stuff, but the variable name must represent something 

here is the according pen http://codepen.io/featuresmega/pen/wzrARJ

Link to comment
Share on other sites

you use a key word that is also used by the code of PhaserJS is group

giving an example means to choose to instanciate the group as an object it self with key/loaded assets images

i have said it's confusing because first of all a group must be understood as a mathematical object (group, ring, ...) so if you take it as from the starting point as an isomorphisme of the key word yoused in the phaserjs code you shoul go into the code it's self ( i know that all this is boring ) and not do a game with it, BUT it's possible to play with it BUT there are given examples,

so in my opinion if you don't play with the word it self and let it to phaserjs many problems IRL can be solved in a funny way and that's the most important thing to notice

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...