Jump to content

Set body of all group sprites?


xronn
 Share

Recommended Posts

Hi,

 

I'm starting to build up a huge number of sprites so I was wondering instead of setting the same body value for each sprite as shown below;
 

beachnpc = this.add.sprite(810, 6472, 'beachnpc');beachnpc.body.setSize(70, 70, 0, 0);beachnpc.body.immovable = true;beachnpc.body.moves = false;forestnpc= this.add.sprite(1110, 3472, 'forestnpc');forestnpc.body.setSize(70, 70, 0, 0);forestnpc.body.immovable = true;forestnpc.body.moves = false;warriornpc= this.add.sprite(3110, 1860, 'warriornpc');warriornpc.body.setSize(70, 70, 0, 0);warriornpc.body.immovable = true;warriornpc.body.moves = false;


So I was trying to put that repeat code into a group as shown:

questnpc = this.add.group();this.physics.enable(questnpc, Phaser.Physics.ARCADE);questnpc.body.setSize(70, 70, 0, 0);questnpc.body.immovable = true;questnpc.body.moves = false;

But I get undefined 'setSize' is it possible to do something like this? Or do I have to repeat all of my code for each sprite?

 

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...