I have created several sprites with phaser and I have stored them in an array.
function createShip(x,y,angle,ship){
var s = game.add.sprite(x,y,ship);
s.rotation = angle;
s.anchor.setTo(0.5,0.5);
return s;
}
for(var i in data){
if(others[i] == undefined && i != socket.id){
var d = data[i];
others[i] = createShip(d.x,d.y,d.angle,d.ship);
}
found[i] = true;
if(i != socket.id){
others[i].x = data[i].x;
others[i].y = data[i].y;
others[i].rotation = data[i].angle;
others[i].ship = data[i].ship;
}
}
I have tried to add these lines of code that I saw in the Phaser documentation
game.physics.startSystem(Phaser.Physics.ARCADE);
game.physics.arcade.enable(others);
and in the Update function
game.physics.arcade.collide(others);
where others is the array that stores all the sprites, but this still does not work