Jump to content

Is there any way to create new objects, and have them be associated with existing sprites?


Grandy12
 Share

Recommended Posts

I'm trying to give each character an individual shadow, and tried something like;

player = fighters.create(32, game.world.height - 153, 'pCharacter');	player.anchor.setTo(0.5, 0.5); 	player.scale.setTo(2, 2); 	game.physics.arcade.enable(player); 	game.camera.follow(player) 	player.body.collideWorldBounds = false; 	player.animations.add('walk', [0,1,2,3,4], 10, true); 	player.shadow = new Shadow(player);function Shadow(character){	shadow = fighters.create(character.body.position.x, character.body.position.y + character.height / 2 -1, 'shadow');	shadow.anchor.setTo(0.5, 0.5);	shadow.scale.setTo(2, 2);	game.physics.arcade.enable(shadow);	shadow.body.collideWorldBounds = true;	shadow.body.setSize(31,4,0,6); 	shadow.body.immovable = true; }

I thought this would create a new object that could be manipulated with 'player.shadow' (as in, player.shadow.body.x = player.body.x), but it didn't work; player.shadow returns "Shadow { }"

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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