Multi-animation HP Bar Help

Non-platform specific questions.

Multi-animation HP Bar Help

Postby D3Ateliers » Sat Oct 06, 2012 2:13 am

I am currently creating a fighting game and need help with the HP bar. I created it using multipole animations and ran into a problem... how do I make the game look for what animation it is?
Ex.

From:
P2_100

To
P1_90
-Bourg, CEO of D3ateliers
User avatar
D3Ateliers
 
Posts: 11
Joined: Mon Aug 06, 2012 4:26 am
Score: 1 Give a positive score

Re: Multi-animation HP Bar Help

Postby skydereign » Sat Oct 06, 2012 5:18 am

There is an actor variable called animindex which tells you which animation an actor has (0 is the first animation in the actor's list, 1 is the second, and so on). It doesn't sound like that is really what you want, though it does answer the question.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Multi-animation HP Bar Help

Postby D3Ateliers » Sat Oct 06, 2012 4:54 pm

Thanks, you helped alot. This is the code I used:


Code: Select all
if(animindex=10) ChangeAnimation("P2_HP", "P2_90", FORWARD);
-Bourg, CEO of D3ateliers
User avatar
D3Ateliers
 
Posts: 11
Joined: Mon Aug 06, 2012 4:26 am
Score: 1 Give a positive score

Re: Multi-animation HP Bar Help

Postby D3Ateliers » Sat Oct 06, 2012 5:11 pm

Found another glitch with this.. How can I make this code:

Code: Select all
if(animindex=10) ChangeAnimation("P2_HP", "P2_90", FORWARD);
if(animindex=9) ChangeAnimation("P2_HP", "P2_80", FORWARD);
if(animindex=8) ChangeAnimation("P2_HP", "P2_70", FORWARD);
if(animindex=7) ChangeAnimation("P2_HP", "P2_60", FORWARD);
if(animindex=6) ChangeAnimation("P2_HP", "P2_50", FORWARD);
if(animindex=5) ChangeAnimation("P2_HP", "P2_40", FORWARD);
if(animindex=4) ChangeAnimation("P2_HP", "P2_30", FORWARD);
if(animindex=3) ChangeAnimation("P2_HP", "P2_20", FORWARD);
if(animindex=2) ChangeAnimation("P2_HP", "P2_10", FORWARD);
if(animindex=1) ChangeAnimation("P2_HP", "P2_00", FORWARD);
if(animindex=1) DestroyActor("p2");


Not go through all of these codes at once while keeping the one script? Right now it automatically kills P2.
-Bourg, CEO of D3ateliers
User avatar
D3Ateliers
 
Posts: 11
Joined: Mon Aug 06, 2012 4:26 am
Score: 1 Give a positive score

Re: Multi-animation HP Bar Help

Postby skydereign » Sat Oct 06, 2012 7:39 pm

That isn't how you use an if statement. If you want to compare, you use == instead of =. Using animindex=10 would set animindex equal to 10, and then run the code (but animindex can't be set, so it just triggers the ChangeAnimation. And again, this probably isn't what you want. Is P2_HP the event actor? Have you looked at normal hp bar demos?
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Multi-animation HP Bar Help

Postby D3Ateliers » Sat Oct 06, 2012 7:54 pm

yes, I have, but I wasn't think while I made this. I will just make a single animation file for it, it will make it easier overall anyways. Thanks for the help.
-Bourg, CEO of D3ateliers
User avatar
D3Ateliers
 
Posts: 11
Joined: Mon Aug 06, 2012 4:26 am
Score: 1 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest

cron