loover Posted September 12, 2016 Share Posted September 12, 2016 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 More sharing options...
rich Posted September 12, 2016 Share Posted September 12, 2016 The code is fine, are you sure you're using a recent enough version of Phaser? Support for this was only added not very long ago. Link to comment Share on other sites More sharing options...
douglas Posted September 12, 2016 Share Posted September 12, 2016 http://codepen.io/featuresmega/pen/NRxxVG ? i don't have the keys and loaded assets to have an idea of the error Link to comment Share on other sites More sharing options...
rich Posted September 12, 2016 Share Posted September 12, 2016 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. Link to comment Share on other sites More sharing options...
loover Posted September 13, 2016 Author Share Posted September 13, 2016 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 More sharing options...
rich Posted September 13, 2016 Share Posted September 13, 2016 You posted a codepen link, asking us to look at it. I did, and it contained code that won't work. How can we help if it's an incomplete example? Phaser 2.2.2 doesn't have 'onChildInputDown' Link to comment Share on other sites More sharing options...
loover Posted September 13, 2016 Author Share Posted September 13, 2016 This link post douglas6500 Anyway, thanks. One more question, how to use Loader in 2.6.2 version to load assets not in "preload" function? Link to comment Share on other sites More sharing options...
douglas Posted September 13, 2016 Share Posted September 13, 2016 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 More sharing options...
loover Posted September 13, 2016 Author Share Posted September 13, 2016 Yes, but it just for simplisity. Link to comment Share on other sites More sharing options...
douglas Posted September 13, 2016 Share Posted September 13, 2016 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 More sharing options...
Recommended Posts