PDA

View Full Version : My platform game!!!!!!!!!!!:(



kickapk
September 6th, 2005, 12:08 AM
ok in my game i want a code so that when the default enemy (the square)
comes in collision with spiderman, the health bar up at the top width goes down 10.
Someone Please help!!!!!!!!!!!!!!

http://media.putfile.com/spideygame44

TheCanadian
September 6th, 2005, 03:02 AM
Look up MovieClip.hitTest() and _xscale in the Flash Help File. Then experiment with this (put on the spiderman movie clip):


onClipEvent (enterFrame) {
if (this.hitTest(_root.box)) {
_root.healthbar._xscale -= 10;
}
}

It uses the hitTest method to check for a collision between the two movie clips. Id it is returned true, there is a collision between the two and the code within the if() statement executes. It then uses the _xscale property to adjust the horizontal scale of the health bar. Feel free to ask more.