Forum Topic: hitTest

(135 views • 5 replies)

This topic is 1 page long.

<< < > >>
Questioning

punkr0cker014

Reply To Post Reply & Quote

Posted at: 1/30/06 06:33 PM

punkr0cker014 NEUTRAL LEVEL 05

Sign-Up: 11/25/05

Posts: 50

i hae a problem with the hitTest function. i have a movieClip of a shot and i duplicate it to come from a gun. Now i have in the shot movieClip near the end the action removeMovieClip(this); but i want it that when the shot hits the wall i want it to skip to a little bit later in the shot clip to where the shot explodes. This is the part that doesnt work. Any suggestions?

AS

onClipEvent(load){
i = 0
}
onClipEvent(mouseDown){
_root.shot.duplicateMovieClip("shot"+i, i);
_root["shot"+i]._x = _root.gun._x;
_root["shot"+i]._y = _root.gun._y;
i++
}
onClipEvent(enterFrame){
if(_root["shot"+i].hitTest(_root.wall)){
_root.shot.gotoAndPlay(20;
}
}


None

scottmale24

Reply To Post Reply & Quote

Posted at: 1/30/06 06:40 PM

scottmale24 DARK LEVEL 20

Sign-Up: 08/13/01

Posts: 11,304

_root.shot.gotoAndPlay(20;
should be
_root.shot.gotoAndPlay(20);

but other than that, I have no idea.

Webcomic - Sig art by Shalonesk
Nipple edited out to make forum-acceptable

BBS Signature

None

punkr0cker014

Reply To Post Reply & Quote

Posted at: 1/30/06 06:43 PM

punkr0cker014 NEUTRAL LEVEL 05

Sign-Up: 11/25/05

Posts: 50

At 1/30/06 06:40 PM, scottmale24 wrote: _root.shot.gotoAndPlay(20;
should be
_root.shot.gotoAndPlay(20);

but other than that, I have no idea.

Yea sorry it is like that i just typed it out in here n guess i didnt catch it. So the problem is still there


None

Vengeance

Reply To Post Reply & Quote

Posted at: 1/30/06 06:46 PM

Vengeance EVIL LEVEL 28

Sign-Up: 03/18/05

Posts: 5,049

you could run a for in loop on the enterFrame
onClipEvent(enterFrame){
for(i in _root){
if(_root[i]._name.indexOf("shot") !=-1){
if(_root[i].hitTest(_root.wall)){
_root[i].gotoAndStop(20);
}
}
}
}
that aught to work.

========|| WWWWWWWW>[-[Blog] - [Audio] - [Userpage] - [Flash] - [Last.fm]-]<WWWWWWWW ||========

BBS Signature

Happy

Digimaks

Reply To Post Reply & Quote

Posted at: 1/30/06 06:47 PM

Digimaks NEUTRAL LEVEL 10

Sign-Up: 08/27/04

Posts: 8

reason why that don't work because you tell _root.SHOT.blah blah.
when you are creating multiple shots with multiple instance names- you got
"SHOT"+ i
so your real instance names are- shot1,shot2,shot3, ect. (you can prove it with a trace statement)
I mean you did it correct with the hitTest where you put "SHOT"+ i hit test . blah blah,
but you left a default "shot" name in the last (gotoAndPlay) statement.

(ps- in case that don't work you can put the hitTest script on the clip that you duplicating. so when you duplicate your shots with mousedown you will have the script inclided on these shot MCs)


None

punkr0cker014

Reply To Post Reply & Quote

Posted at: 1/30/06 06:58 PM

punkr0cker014 NEUTRAL LEVEL 05

Sign-Up: 11/25/05

Posts: 50

-Vengeance- your script didnt work.
Iron thanks for the last idea of putting it into the original shot. Now all i have to do is make it stop at the wall instead of going through until it reaches the frame where it explodes.


All times are Eastern Standard Time (GMT -5) | Current Time: 12:39 PM

<< Back

This topic is 1 page long.

<< < > >>
You need a Grounds Gold Account to post on the NG BBS! If you don't have one, click here to sign up now! It's fast, free, and easy — and opens up tons of great NG features!