/ Forside / Teknologi / Multimedie & design / Flash / Nyhedsindlæg
Login
Glemt dit kodeord?
Brugernavn

Kodeord


Reklame
Top 10 brugere
Flash
#NavnPoint
bentjuul 4251
molokyle 1978
Klaudi 1488
jhvp 1265
pallenoc 1160
katekismus 1020
Fnollerpi.. 790
slander 510
Dr.Disco 500
10  Flash77 500
collision detection in Flash
Fra : Ben Haldenby


Dato : 10-04-01 15:04

Hello everyone,

This is my first posting to this group so I apologise if this issue has come
up before. I'm developing a simple game and using hitTest to detect when two
movie clips collide. Let me explain...
My first movie clip is a 'cricket ball' with a 15 frame tweened animation of
the ball disappearing into the distance (kind of simulating a throwing
motion) This is done with a motion path. On the first frame of this movie
clip I have the following script:
stop()
Mouse.hide();
startDrag (theball, true);

So this hides the cursor and makes the ball instance follow the mouse. Back
on the main stage I have this script attached to the ball movie clip itself:
onClipEvent (mouseDown) {
tellTarget (theball) {
play ();
stopDrag ();
}
}

So on mouse down this plays the movie clip (the throwing action) and stops
dragging. The movie clip then loops when it reaches frame 15 and we are back
at the start. Here comes the tricky bit. The second movie clip is a square
with two frames, the first tells the movie to
stop(); and the second adds an explosion to the square and goes back to
frame 1. I want the final frame of my ball movie to carry the
collision/hitTest script, but it doesn't work:
onClipEvent (enterFrame) {
if (this.hitTest(_root.streaker ) == true) {
tellTarget (_root.streaker) {
gotoAndPlay(2);
}
}
}

I can make it work if the ball instance carries the hiTest script, but thats
means the collision is detected always and I only want it to occur when the
ball 'hits the target'. I hope this is all clear and that someone can help
me, I'm pulling my hair out.

Thanks in anticipation,
Ben



 
 
Søg
Reklame
Statistik
Spørgsmål : 177558
Tips : 31968
Nyheder : 719565
Indlæg : 6408926
Brugere : 218888

Månedens bedste
Årets bedste
Sidste års bedste