Code trouble making healthbar

Game Editor comments and discussion.

Code trouble making healthbar

Postby Yorae » Mon Jan 03, 2011 3:49 am

Basically all I need to know is what's wrong wih this code I'm trying to use:

if collissionnum.textnum = one.textnum healthbarguitar ChangeAnimation("healthbarguitar", "80 health", FORWARD);

I want the health bar animation to change each time the 'collissionnum' actor's textnum is the same as 'one'

can you help?
Yorae
 
Posts: 4
Joined: Mon Jan 03, 2011 3:43 am
Score: 0 Give a positive score

Re: Code trouble making healthbar

Postby skydereign » Mon Jan 03, 2011 4:08 am

Well that doesn't sound very optimal, but the if statement needs to be like this.
Code: Select all
if(collisionnum.textNumber==1)
{
    ChangeAnimation("healthbarguitar", "80 health", FORWARD);
}


collisionnum is a text actor, since textNumber is an actor variable only used by text actors.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Code trouble making healthbar

Postby Yorae » Mon Jan 03, 2011 5:05 am

I've uploaded my project file as the attachment, the last comment didn't seem to work, so I was hoping you might be able to take a look and fix it for me? :P since it is probably a vey simple thing that I am doing wrong.

I need the healthbar's animation to change to a different animation under the different circumstances: if collissionnum = 6, 12, 18 and 24 (different animation is there for each different number)
Attachments
Broken Chord.rar
(845.25 KiB) Downloaded 76 times
Yorae
 
Posts: 4
Joined: Mon Jan 03, 2011 3:43 am
Score: 0 Give a positive score

Re: Code trouble making healthbar

Postby skydereign » Mon Jan 03, 2011 5:53 am

Here it is. A tip... You have two of the same event (collision events in this case), they should be condensed into one script. The collisionnum.textNumber=collisionNum.textNumber + 1; script should be at the beginning of the second collision event. I fixed it in the file. Also the mistakes you had were both spelling mistakes. collisionnum and textNumber.
Attachments
brokenChord.zip
(596.55 KiB) Downloaded 71 times
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Code trouble making healthbar

Postby Yorae » Tue Jan 04, 2011 12:19 am

thanks for trying to help, but when I opened that up it still didn't seem to work :/
Yorae
 
Posts: 4
Joined: Mon Jan 03, 2011 3:43 am
Score: 0 Give a positive score

Re: Code trouble making healthbar

Postby skydereign » Tue Jan 04, 2011 6:13 am

What do you mean it doesn't work? What error does it give?
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Code trouble making healthbar

Postby Yorae » Wed Jan 05, 2011 2:50 am

It isn't that the code itself comes up with errors, it is simply that the code doesn't do what I want :/ the code still has no effect on the healthbar like I want it to.
Yorae
 
Posts: 4
Joined: Mon Jan 03, 2011 3:43 am
Score: 0 Give a positive score

Re: Code trouble making healthbar

Postby schnellboot » Wed Jan 05, 2011 8:43 am

yeah .. but your whole game is not finished xD
finish your movements and attacks first then you fix your healthbar
schnellboot
 
Posts: 819
Joined: Sat Mar 31, 2007 1:35 pm
Location: Germany
Score: 102 Give a positive score


Return to GE - General

Who is online

Users browsing this forum: No registered users and 1 guest

cron