Copy link to clipboard
Copied
Hi,
I still have some problem thinking about my code and how I should do it. (Beginner here!)
The question is that I want to create a 'party' member code for 10 heroes or more with all separated stats.
I wonder if I should create an array that I send it everywhere or there is an another solution, like a temporary files that stock up and save.
The array should look like this:
lvl 1 of the array: Party section
lvl 2 of the array: name,xp,attack,defence, lvl of the character.
Exemple : [['rodolf',1300,3,4,78],['Baaaaa',1301,4,3,79],['mukmuk',103,2,3,80], etc...]
I know that I can pop when a character die or leave the party, but I feel that its not a good solution for all of this. Cause the party is a very active variable and can change a lot of times. So I need your help to guide me! Please!
Thank you for reading my problem and try to help me!
use an object:
var obj:Object={};
updateParty('rudolf',1300,3,4,78);
function updateParty(nameS:String,_xp:int,_attack:int,_defense:int,_lvl:int):void{
obj[nameS]={xp:_xp,attack:_attack,defense:_defense,lvl:_lvl};
}
function retrieveParty(nameS):Object{
return obj[nameS];
}
///////////////
// then if you want to retrieve the lvl of mukmuk, use:
trace(retrieveParty('mukmuk').lvl);
Copy link to clipboard
Copied
use an object:
var obj:Object={};
updateParty('rudolf',1300,3,4,78);
function updateParty(nameS:String,_xp:int,_attack:int,_defense:int,_lvl:int):void{
obj[nameS]={xp:_xp,attack:_attack,defense:_defense,lvl:_lvl};
}
function retrieveParty(nameS):Object{
return obj[nameS];
}
///////////////
// then if you want to retrieve the lvl of mukmuk, use:
trace(retrieveParty('mukmuk').lvl);
Copy link to clipboard
Copied
Yeah its sound pretty good! I forgot that I could use object too! Thank you a lot
Copy link to clipboard
Copied
you're welcome.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now