Heppell08 Posted January 25, 2014 Share Posted January 25, 2014 I have seen a post on this and it said to create the player as a group and load on sprites on sprites like that. I figured if i have a group called weapons, load my weapons in that group and give it the player as the parent and they follow as they should. That's all fine for now but my issue is the lag. The gun seems to trail behind and not look like its stuck to the player. I was wondering if there was a way to create the visuals of the gun being stuck to the player with my weapon group and player parent set up?My group looks like this so far:weapons = game.add.group(player); for(var k = 0; k < 1; k++) { gun1 = game.add.sprite(5, 5,'gun1'); gun1.scale.x = 0.35; gun1.scale.y = 0.35; } Link to comment Share on other sites More sharing options...
Heppell08 Posted January 25, 2014 Author Share Posted January 25, 2014 Fixed it. Code: weapons = game.add.group(player); for(var k = 0; k < 1; k++) { gun1 = weapons.create(5, 8,'gun1'); gun1.scale.x = 0.20; gun1.scale.y = 0.20; gun1.anchor.setTo(0.5, 0.5); }Then scaled the image with left/right:if(cursors.left.isDown) { player.body.velocity.x = -150; if(facing !== 'left') { gun1.scale.x *=-1; facing = 'left'; } } else if (cursors.right.isDown) { player.body.velocity.x = 150; if(facing !== 'right') { gun1.scale.x *=-1; facing = 'right'; } } jpdev 1 Link to comment Share on other sites More sharing options...
Heppell08 Posted January 25, 2014 Author Share Posted January 25, 2014 Might also be worth noting I did put gun.x = player.x; in my update prior to my fix. I have since removed that update code and all working well. Link to comment Share on other sites More sharing options...
Recommended Posts