Shootorial Health Bar Help!

Subscribe to Shootorial Health Bar Help! 11 posts, 5 voices

Sign in to reply


 
avatar for bif490 bif490 263 posts
Flag Post

OK, so I’m on the shootorials, and I got to #6 with no problems, i made a working score counter, but my health bar won’t work. I copied the same one from the example (the green one) and I put in all the scripting stuff (and double checked it), and there are no errors, but when I play my game, everything works perfectly, except my ship cant lose health! any help would be nice!

 
avatar for Jabor Jabor 9699 posts
Flag Post

The best way to debug something like this is to stick a few trace() statements throughout your code, to see what’s happening and what isn’t.

 
avatar for bif490 bif490 263 posts
Flag Post

Can I just stick them anywhere, or should I put them in the functionOnload place? Whatever, I’ll try.

 
avatar for bif490 bif490 263 posts
Flag Post

.

 
avatar for Cervello Cervello 76 posts
Flag Post

You put trace statements before/after pieces of code to check that they’re running properly.
When you test the game, it appears in the output whenever the code goes through the trace.

For example, you would put trace(heath); after health-=damage; or whatever code it is that does that to make sure health is being properly reduced – if it is, the health would be outputted each time you take damage. Remember to take them out once your’re done with them.

 
avatar for bif490 bif490 263 posts
Flag Post

When I put in the trace thing, whatever actionscript i put it in, doesnt work. for example, if i put it in the enemyship class, no enemy ships come, or if i put it in the enemy missile class, the bullets stay where they are shot from.

 
avatar for bif490 bif490 263 posts
Flag Post

also, when I put them in, the one error that comes up EVERY time is: "The class or interface ‘bar’ could not be loaded. If that is what is causin g the problem, what can I do to fix it.?

 
avatar for explodingferret explodingferret 1350 posts
Flag Post

You probably have “bar” in the class box in the properties of your health bar movieclip, when you should have “Bar”

 
avatar for bif490 bif490 263 posts
Flag Post

Yeah, i did have bar instead of Bar, but that still hasn’t fixed the problem, thanks for your help though!

 
avatar for Cervello Cervello 76 posts
Flag Post

Well….I’m honestly clueless to exactly how you can screw up the change from:
function updateHealth(points) { health += points; _root.healthMeter.bar._xscale = health; }
to
function updateHealth(points) { health += points; trace(health); _root.healthMeter.bar._xscale = health; }

But at this point I think you simply forgot to give the bar in the healthMeter Movieclip an instance name.

Also, consider editing your posts instead of double-posting.
You can even delete posts after editing!

 
avatar for Fargren Fargren 14 posts
Flag Post

I’m having the same problem. I did a trace, and the health var is actually decreasing when I get hit, but the life bar still isn’t changing.
Oh, and I know that many people were not initilizing the health. That’s denifnettly not the problem I’m having.
Edit: solved

Sign in to reply


Click Here