ramspeed Posted February 5, 2016 Share Posted February 5, 2016 Hey everyone, how do I create an array of groups? I've tried things similar to this.groupArray.push(this.add.group()); Thanks Link to comment Share on other sites More sharing options...
AzraelTycka Posted February 5, 2016 Share Posted February 5, 2016 Hello, well where is the problem? When you are asking I suppose your approach didn't meet with the expected result? Link to comment Share on other sites More sharing options...
ramspeed Posted February 5, 2016 Author Share Posted February 5, 2016 I receive a "Cannot read property 'group' of undefined" when I try instantiate and add group to array. I know this is more of a general javascript question than Phaser-specific but I thought I'd ask. - Thanks Link to comment Share on other sites More sharing options...
AzraelTycka Posted February 5, 2016 Share Posted February 5, 2016 Well console says it's undefined so check that out first, if it's undefined you need to find out what exactly and why it is undefined. If you can share your code it might give us an idea, at least you should upload your code to jsfiddle or similar service so we can test it. But first use console.log(this); and check what you are refering to as this object. So far not much to say without the code itself (try to strip the code of eveyrthing but the problematic part, there is no need to put here your netire code no one is gonna read it anyway if it's too long so leave only the problem itself upload it to jsfiddle and test only this short piece of code yourself that way you can test only the functionality you are having a problem with. Link to comment Share on other sites More sharing options...
ramspeed Posted February 5, 2016 Author Share Posted February 5, 2016 Thanks for your help Azrael. I can confirm this.groupArray.push(this.add.group()) works fine. Error on my part. Link to comment Share on other sites More sharing options...
Recommended Posts