View Full Version : Need help with Zombie Game
wayzey
06-15-2008, 12:29 PM
I have put movieclips inside the zombie movieclip so there is head, body and legs inside the one clip. Now I put the code:
onClipEvent(enterFrame){
if(hitTest(_root.laser2)==true){
gotoAndPlay(2);
}
}
On the movie clip head and then I tried it out and it wouldn't work.
Any help?
GMaker0507
06-15-2008, 06:08 PM
First how fast are your bullets moving. If the speed of a bullet is larger than the length of the object then there is a chance flash wont detect any collision
This is because:
If the bullet is positioned at (0,0) moving 100 pixels to the right.
And, the object is is positioned at (10,0) and is 50 pixels wide.
Then flash wouldnt detect any collision because at one frame its at (0,0) the next, it is at (100,0), flash doesnt do anything for the in between 100 pixels. Its kinda like teleporting.
You could, slow down your bullets speed and if you want to, speed up your FPS, but that might mess up the look and flow of your game.
I know of other ways, but that involves more math. Are you familiar with vectors? and applying them to games?
are you sure there is an Mc on the root stage named laser2, or is that name just for example.
That seems right.
onClipEvent(enterFrame){
if(this.hitTest(_root.laser2)){
this.gotoAndPlay(2);
}
}
Do you get an error?
Besides all of that, i might need to see some more code to help
wayzey
06-15-2008, 10:56 PM
No i get no error
I thought it could have been what you said a few days ago so i changed speed of bullet to 5 pixels a frame and it still didn't work.
The movieclip I am making the bullet hit is inside of another movieclip, does this matter?
So I have the movieclip laser2, then I also have the movieclip Zombie, inside Zombie are head, chest and legs, I have put that code on Head.
GMaker0507
06-16-2008, 04:32 AM
It doesnt matter if they are nested in another movieclip
i guess i would have to see some more of you code to know more,because everything your tellin seems right
wayzey
06-16-2008, 12:16 PM
it's ok i worked out the problem, another hit test was overlapping that one.
|
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.