Um that was a typo. I didn't actually write that in the fla. but, I figured out the problem. There was a line of code in the timeline that I missed. I had been looking within the movieclip, but it was on the outside. it works now. Thanks for your help though!
hey im having a problem with my enemy dieing when he is hit by my "player" here is the code
onClipEvent(load){
_x = Math.round(_x/5)*5;
_y = Math.round(_y/5)*5;
}
onClipEvent(enterFrame){
dx = _parent.player._x - _x; // distance between them
d = Math.sqrt(dx*dx+dy*dy);
// I take _width as being the distance between the two clip's centers
if(d > 20 && d < 250){
// Find angle to travel: (180/Math.PI) converts radians to degrees
_rotation = Math.atan2(dx, -dy)*(359/Math.PI);
// Travel that way
_x -= Math.sin(_rotation)*20; // 5 is speed
}
if(_x-25 > _root.player._x+15){
_x-=5;
} else {
this.gotoAndStop("attack")
}
} \\BELOW IS WHERE IM HAVING THE PROBLEM AND IT'S PROBABLY EASY TO FIX
onClipEvent(enterFrame) {
if(hitTest(_root.windmillring)) {
gotoAndPlay ("die");
}
}
i have the "die" movieclip in the enemy and when he hits the windmillring i want it to play "die"
I have a problem in my Shoot-down-enemy-space-ships game. if i have 10 space ships flying down the screen, and a gun which shoots bullets, how can i quikly find out if the ship has been hit. this is the code that i have used so far:
So heres the set up---
There's a movie clip as the mouse called mouse1, and inside that, there's a dynamic text box called mousehit. There is another movie clip on the screen, a painting, and I want it so that when the mouse is over the painting, the dynamic text box says "Painting"
alright, alright. I figured instead of starting a new thread, i would just post here, since my problem is a hitTest problem.
I printed David Doull's tutorial here in Flashkit on making a spaceship side scroller. I went through it a few months ago, and got the game to work....for the most part. But i lost the files and decided to redo it. Here is my problem:
I have the baddies coded to hitTest for the "spaceship". If so, then the movie goes to frame 3 "gameOver".
that didn't work. So, i put the hitTest on the spaceship to test against the enemy. That didn't work.
I even tried changing the gotoAndStop from "gameOver" to frame number 3. Still, no dice. And this worked before! Maybe its a stupid mistake im overlooking? here is my code:
Code:
//enemy test for spaceship
if(this.hitTest(_root.spaceship)){
_root.gotoAndStop("gameOver");
}
Code:
//spaceship test for enemy
if(this.hitTest(_root["enemy"+i])){
_root.gotoAndStop("gameOver");
}
I know this code is right. They are both under onClipEvent(enterFrame) actions. But it still doesn't work!
Furthermore, i know that all the movie clips are named properly in the code, and the frame label is not misspelled....i quadruple checked all of this!!
Didn't read all messages before posting... (only read the first page. didn't see that there was more).
The other posts answered my question... that it's not possible.
Okay, here is my code for the hittest in my game. The problem is it checks the bounding box and not the actual image shape. So I get collisions when it does not look like I should. How would I fix this.