marros1812 Posted December 31, 2015 Share Posted December 31, 2015 ok so I am trying to make weapons that my player can use to attack enemies. I've been following this http://thoughts.amphibian.com/2015/11/attacking-enemies-in-my-phaser.html. When I go to run my game I am getting an error: Uncaught TypeError: weapons.createMultiple is not a function As far as I can see that shouldn't be a problem, according to the docs, createMultiple should work, any ideas? Link to comment Share on other sites More sharing options...
lewster32 Posted December 31, 2015 Share Posted December 31, 2015 Show us your code - I suspect weapons is not what you expect it to be. You can also just do console.log(weapons) just before where your problem is and see what type of object weapons is referring to. Link to comment Share on other sites More sharing options...
marros1812 Posted December 31, 2015 Author Share Posted December 31, 2015 This is the code that I have at the beginning, the error is happening on the second lineweapons = game.add.group;weapons.createMultiple(3, 'sword', 0, false); Link to comment Share on other sites More sharing options...
CtlAltDel Posted December 31, 2015 Share Posted December 31, 2015 game.add.group(); Link to comment Share on other sites More sharing options...
marros1812 Posted December 31, 2015 Author Share Posted December 31, 2015 game.add.group(); this doesn't seem to work Link to comment Share on other sites More sharing options...
CtlAltDel Posted December 31, 2015 Share Posted December 31, 2015 http://phaser.io/examples/v2/groups/create-sprite-in-a-group so it should work. Link to comment Share on other sites More sharing options...
marros1812 Posted December 31, 2015 Author Share Posted December 31, 2015 as far as I can see it makes the group fine but it says that weapons.createMultiple isn't a function, but it is, it should work as far as I can see. Link to comment Share on other sites More sharing options...
lewster32 Posted January 1, 2016 Share Posted January 1, 2016 It's definitely game.add.group() with the parentheses as CtrlAltDel points out. What happens if you do console.log(weapons) after you create the group? You should have an instance of c.Group, and in its __proto__ property (it inherits from b.DisplayObjectContainer) should be the createMultiple function. Link to comment Share on other sites More sharing options...
Recommended Posts