PDA

View Full Version : keeping score and detecting lives



bombsledder
February 21st, 2004, 10:56 AM
alright you are all probably tired of answering my questions,but

im trying to create a dynamic text box so when there is a hit

collision between my two objects. say a ball and another ball a life

is deducted from the life text box. and at 0 lives you goto the 2nd

frame.

thanks for all the help

lenf
February 21st, 2004, 03:26 PM
onClipEvent(enterFrame){
if(this.hitTest(_root.ball2)){
_root.life = _root.life - 1;
}
if(_root.life == 0){
gotoAndStop(2)
}
}

bombsledder
February 21st, 2004, 06:08 PM
yes thanks i just have one problem.

when (well in my case a ball hits the rectangle and the score just

keeps going down.

i want it to play from the beginning but with one life less, and

when zero lives left play()2.

do you think you can tell me whats rong, and if you dont

understand i will try saying in easier

bombsledder
February 21st, 2004, 06:10 PM
o wate if you want i can attach the file and put it on a new thread!

lenf
February 22nd, 2004, 06:24 AM
what do you mean?

bombsledder
February 22nd, 2004, 12:34 PM
o sorry yea that is sort of comfusing alright ill say it simple

my game has 2 long rectangles on both sides of the screen

circles ae bouncing from each wall to the other wall

well my character is a small rectangle. and when he hitTests the

ball the score subtraces but brings it down to like -1 and the 0

will not bring you to another frame. i also want it so when you

lose 1 life you goto the beginning of the frame. but it doesnt do

that. Like i said before if you want me to attach the fla just tell me

REEFˇ
February 22nd, 2004, 01:43 PM
Wait, what are you trying to test? The ball touching the character? The ball touching the ball2? Put this on your character if the character is touching the ball:

on (load) {
// Set a certain amount of life:
_root.life = 5;
}
on (enterFrame) {
// If the ball touches your character:
if (_root.ball.hitTest(this)) {
// Decrement the life:
_root.life--;
// Stop at the beginning of the movie:
_root.gotoAndStop(1);
}
// If the life is or less than 0:
if (_root.life <= 0) {
// Go to and Play at frame 2:
_root.gotoAndPlay(2);
}

bombsledder
February 22nd, 2004, 03:35 PM
alright one problem with that script every time my character hits

the ball it goes to the next frame not frame 3 like i want it 2

and i tried adjusting the script and all i got was subtracting

but no actions....???

so comfused