|
-
[ASK] Character Customization
Hi, I want my player to be able to customize his character/avatar and have the character with that same appearance inside the game. If possible different kind of equips can have its own capability (e.g: shotgun spread, machine gun). And each part have their own collision detection, like bigger parts have bigger collision area.
Something like this:
http://www.kongregate.com/games/Hero...e=bubble+tanks
Or maybe like this first for a start:
http://www.kongregate.com/games/Jigg...tform-racing-2
http://www.kongregate.com/games/Berz...plete=commando
It doesn't have to be able to save the avatar for the moment, just create one avatar for each play is nice.
Could someone point me where/how to learn or start?
Last edited by Icecage; 08-30-2010 at 04:17 PM.
-
Senior Member
Just make multiple movieclips for different parts(head,body,...), and inside each movieclip, on all the frames put the images for that part. Now nest all these movieclips under the same mc, and then it's as simple as using gotoAndStop for the customisation.
If you like me, add me to your friends list  .
PS: looking for spriters and graphics artists for a RPG and an Arcade fighting project. If you can help out, please pm me!
My Arcade My Blog
Add me on twitter: 
-
Ok, so after that I put this code in the main timeline:
PHP Code:
//For weapon
weaponType = charMC.weaponMC(_currentFrame);
function shoot(){
switch(weaponType){
case 1: {handgun mechanics}
case 2: {shotgun mechanics}
case 3: {machinegun mechanics}
}
}
//For armor
bodyArmor = armorValArr[charMC.bodyMC(_currentFrame)];
headArmor = armorValArr[charMC.headMC(_currentFrame)];
etc...
totalArmor = bodyArmor+headArmor+etc;
Am I doing it wrong? Is there an effective way of doing it?
Btw if I put all the parts movieclip into 1 movieclip (character), the collision will be a big square depending on the total height and width.
How do I separate it so each movieclip has its own collision?
-
Senior Member
1) Considering you are using the outdated as2, that's quite effective. However, I would recommend storing the function reference in a variable right after the customisation, so that you don't have to check all the cases every time you shoot. Basically create a set of global variables, and as soon as the customisation is finalised, store total_armor, shooting mechanics, e.t.c in those for easy reference.
2) Use the actual rectangle collision to detect if two characters are colliding, and if they are then do a sublevel collision detection like char.sword.hitTest(enemy.body)
If you like me, add me to your friends list  .
PS: looking for spriters and graphics artists for a RPG and an Arcade fighting project. If you can help out, please pm me!
My Arcade My Blog
Add me on twitter: 
-
 Originally Posted by bluemagica
1) Considering you are using the outdated as2, that's quite effective. However, I would recommend storing the function reference in a variable right after the customisation, so that you don't have to check all the cases every time you shoot. Basically create a set of global variables, and as soon as the customisation is finalised, store total_armor, shooting mechanics, e.t.c in those for easy reference.
I figured it is something like this?
PHP Code:
weaponType = charMC.weaponMC(_currentFrame);
_global.weaponName = weaponNameArray[weaponType]; _global.fireRate = rateArray[weaponType]; _global.bulletDamage = damageArray[weaponType];
But how about functions? Because inside my function shoot() there are other functions depending on the case (e.g: homing(), shotgun()) and each has different mechanics, not only variable values. Something like shotgun spread its shots, and homing missile chases its target.
I called it like this:
Code:
onMouseDown = shoot;
How does it know if it is shotgun or homing if I dont use switch case or if statement?
 Originally Posted by bluemagica
2) Use the actual rectangle collision to detect if two characters are colliding, and if they are then do a sublevel collision detection like char.sword.hitTest(enemy.body)
But wouldn't the sword detects multiple collisions? Like if it hits both body and head the damage would be counted twice. I guess it's fine if I use bullet since the bullet will disappear on collision.
EDIT: Nevermind the 2nd question, I guess I can use a boolean variable like isBeingHit, so the character can only receive damage if isBeingHit = false.
Last edited by Icecage; 08-31-2010 at 12:30 PM.
-
Senior Member
1)
Code:
var attack:function = shotgun;// assuming there's a shotgun() function to fire a shotgun
onMouse...whatever
..... attack();
Well I don't know if as2 would allow typing a var as function, but you can store a reference to a function like that without typing the var.(...sigh...that's why I like as3).
2) Well I suggest having a "damage potential" for melee weapons and dividing it as percentage among the number of collisions.
If you like me, add me to your friends list  .
PS: looking for spriters and graphics artists for a RPG and an Arcade fighting project. If you can help out, please pm me!
My Arcade My Blog
Add me on twitter: 
-
Haha, I wish I know how to use as3. School project deadline on 1 month and not sure if have time to learn it 
Thanks anyway.
-
Pumpkin Carving 2008
But wouldn't the sword detects multiple collisions? Like if it hits both body and head the damage would be counted twice. I guess it's fine if I use bullet since the bullet will disappear on collision.
Loop the collision on the body parts and break the procedure after the first collision is made.
Well I don't know if as2 would allow typing a var as function
You can.
How does it know if it is shotgun or homing if I dont use switch case or if statement?
As Bluemagica suggested, simply create a static function for each type of attack:
Code:
function homingAttack(){...}
function shotgunAttack(){...}
...etc
Give the character a variable such as:
Code:
var attack:Function;
And when the weapon is changed, use the switch statement then to determine the attack and set the attack variable equal to the name of the function:
Code:
function chooseAttack(weaponType:Number):void {
switch(weaponType) {
case 0:
attack = shotgunAttack;
break;
case 1:
attack = homingAttack;
break;
default:
attack = meleeAttack;
}
}
When the character attacks, then simply called the attack var as function:
The 'Boose':
ASUS Sabertooth P67 TUF
Intel Core i7-2600K Quad-Core Sandy Bridge 3.4GHz Overclocked to 4.2GHz
8GB G.Skill Ripjaws 1600 DDR3
ASUS ENGTX550 TI DC/DI/1GD5 GeForce GTX 550 Ti (Fermi) 1GB 1GDDR5 (Overclocked to 1.1GHz)
New addition: OCZ Vertex 240GB SATA III SSD
WEI Score: 7.6
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|