Martiny Posted December 10, 2013 Share Posted December 10, 2013 Hello again everyone, I need to change the body side of every component of a group, but I can't find a way to do it because I need to pass 4 values in body.setSize. Here's the code so far:blueEnemy = game.add.group();blueGuy = blueEnemy.create(100, 100, 'blueEnemy');blueGuy.body.setSize(30, 30, 8, 8);I can set the size of the body if I create a variable that holds that sprite. But since I will create and kill lots of blueEnemy's, I don't know if that's the most practical way. I wanted to do something that would body.setSize(30, 30, 8, 8) in every new blueEnemy, but I don't know if it is possible to use setAll in this case (couldn't find any example of it). What I wanted to do was something like this, but working:blueEnemy = game.add.group();blueEnemy.setAll('body.setSize', [30, 30, 8, 8])blueEnemy.create(100, 100, 'blueEnemy');[30, 30, 8, 8] is not accepted. No error in console, but no affect either. If not possible to use setAll this way, is there a way to change the body size without assigning it to a variable? Thanks for the attention. Link to comment Share on other sites More sharing options...
rich Posted December 10, 2013 Share Posted December 10, 2013 Group.setAll is for setting the value of a single property. Body.setSize is a function, so you'd want to use Group.callAll instead, which can accept any number of parameters:blueEnemy.callAll('body.setSize', '', 30, 30, 8, 8);Depending on your scope you may need to adjust the 2nd parameter (the context that the function is called under). shawnbless and bborncr 2 Link to comment Share on other sites More sharing options...
Recommended Posts