flsg -> RE: Flash Q&A Thread 4 (9/9/2007 15:48:01)
|
hey new people!!! :) welcome for the inventory system, I work in a totally different way. But you COULD just use SeniorBiscuitBut's way if your game is small* althorne: your method is easy for 3 hearts, bu what if you have 180 hearts? then you'll need to use 180 MCs >_< I suggest to use a for loop and attach the heart MC, then re-attach the right number each time(so you won't need to assign an instance variable, and remove the copy heart according to the instance name)
//somewhere...
var heartsNumber:Number=12
function loseLife(num:Number):void{
for(var i:Number=0;i<num;i++){
_root.attachMovie("yourHeartLinkageName", "newName"+i,i)
}
}
//somewhere, when you lose a life
heartsNumber--
loseLife(heartsNumber)
this uses to fact that you override the previous hearts by re-attaching sometime to the same depth(AS2) if this doesn't work(don't have time to test myself right now, sorry), tell me and I'll re-write a code * I didn't read SeniorBiscuitBut's solution, but that should work lol XD
|
|
|
|