toastedbrains Posted July 2, 2015 Share Posted July 2, 2015 Hello, just new to phaser and i was looking at the examples on the phaser site. i want to do something like this : i have a character and he can be upgraded. for example, the character has a pistol for weapon initially. but then he can have a rifle later on. or his head does not have helmet but he can have later on. i'm thinking i can have different spritesheets for each part of the character. one spritesheet for the head, one for body, for weapon, etc. and then combine them all into one main sprite. i saw on the example this : http://phaser.io/examples/v2/groups/group-transform it looks a bit like what i want to do but not quite. mainly, i want each part to contain its own animation.. like maybe the head, it's eyes is moving. and also. how to animate that robot. like, if i press the arrow, it will look like it is walking.. not sure if i epxlained it right so you can go ahead and ask me questions. looking forward to your help. tldr : how can i do this - i have a character that can change his appearance..mainly, he can have diff. weapon or headgear, or even clothes.. if you played ragnarok online, i think you know what i mean. thanks! Link to comment Share on other sites More sharing options...
Account Deleted Posted July 2, 2015 Share Posted July 2, 2015 Many questions Lets break it down. 1. Adding and Removing Equipment. You can have a sprite added as a child onto another sprite so it looks like its being added on. I prefer this to the spritesheet method and swapping out styles, but that's just me. //To start you make the sprite like so.this.sprite = this.game.add.sprite(x,y, 'GUNZERKER'); //Add a Childthis.rifle = this.game.add.sprite(x, y, 'quadrupleRifle');this.sprite.addChild(this.rifle); //Then position as requiredthis.rifle.x = x;this.rifle.y = y;this.rifle.width = width;this.rifle.height = height; 2. How to animate. Rather than typing it all out, check out the standard tutorial, which can explain it better . //Part 1 for the beginning of ithttp://phaser.io/tutorials/making-your-first-phaser-game/part1 //Part 4 has the bit you need, but you should go through all of it.http://phaser.io/tutorials/making-your-first-phaser-game/part4 Hope that helps! Link to comment Share on other sites More sharing options...
toastedbrains Posted July 3, 2015 Author Share Posted July 3, 2015 Hey, thanks Outrider. Going through those links now. Link to comment Share on other sites More sharing options...
toastedbrains Posted July 3, 2015 Author Share Posted July 3, 2015 Oh i think i got it already.. as i already understand how to animate an individual sprite. when adding to a group, it's just the same way. some duh moment for me. lol can't wait to try it out later after my work. thanks again! Account Deleted 1 Link to comment Share on other sites More sharing options...
Account Deleted Posted July 3, 2015 Share Posted July 3, 2015 Glad I could help . Link to comment Share on other sites More sharing options...
Recommended Posts