ikwileten12 Posted December 19, 2014 Share Posted December 19, 2014 Hello I have been looking around for ages trying to get this to work but have not been able to find anything.so i decided to put up a post.basically i am trying to make my character wear a weapon. much like they do it in terraria where the weapon is connected to his hand and tweens downwards. example: http://prntscr.com/5if72i I hope this is enough info. thanks! Link to comment Share on other sites More sharing options...
jpdev Posted December 19, 2014 Share Posted December 19, 2014 var weapon = this.game.add.sprite(0, 50, "weapon");weapon.anchor.set(0, 1);playersprite.addChild(weapon); the "magic numbers" (for the position and the anchor point) of course depend on the size and orientation of the weapon sprite and the size of the player sprite and the position of the players hand. the position of the spirte (0, 50) is relative to the upper left corner of the player sprite. so try to find the hand the anchor for the weapon determines around which point it rotates (that should be the handle) the values are given as a fraction of the weaponsprite size. with addchild the weapon always sticks to the player, and also get's the players scale, rotation and everything. You can then rotate the weapon sprite and it will look like a swing. Link to comment Share on other sites More sharing options...
ikwileten12 Posted December 19, 2014 Author Share Posted December 19, 2014 Thank you so much for your reply. going to test it now Link to comment Share on other sites More sharing options...
Recommended Posts