przemoo83 Posted June 30, 2015 Share Posted June 30, 2015 HiI don't know what is wrong with my code. From what I understand from documentation using 'group.create()' method should add an element to a group and therefore increase group.length. However, it still logs "1" to a console no matter how many objects I add. Can anyone look at this code please?http://phaser.io/sandbox/dUeskoXPIt adds a sprite everytime you click on the screen. Link to comment Share on other sites More sharing options...
rpushin Posted June 30, 2015 Share Posted June 30, 2015 group is not an array, it is a complex object with a lot of different properties. if you want to access all added objects use groupname.children property - it is actual iterable array with lengh Link to comment Share on other sites More sharing options...
rich Posted June 30, 2015 Share Posted June 30, 2015 Because every time showMe is called it's creating a brand new Group (set to the LOCAL var "myGroup") and adding just one sprite to it. So what is actually happening is you're making a new Group on each click, not adding to an existing one. Link to comment Share on other sites More sharing options...
przemoo83 Posted June 30, 2015 Author Share Posted June 30, 2015 Thank rich. Really stupid mistake. Turning my group into a global variable and calling it in a function was enough to make it work:) Link to comment Share on other sites More sharing options...
Recommended Posts