开发者

Survivor game (ennemies going through walls, hitTest and flashlight)

I posted a bit earlier about some problems I had with a game I'm trying to do. Here is the .fla file : http://ifile.it/bpi79cv .

My first and main problem is that the ennemies are going through the walls. I can do a hiTest like with the player so that the collision is detected, but I don't know how to make the ennemy change direction. I thought it would be quite simpler if the ennemies could not move simultaneously on the x and y axis, but don't know how to do i开发者_如何学Ct. (then they would only need to make a 90 degrees turn)

Second problem is the hitTest for detecting collisions with the ennemies. It seems like I'm not able to do it. There is the part which I thought would be good at the end of the script in commentary.

Third problem, which is the least important in my eyes is that we see the ennemies even if the "flashlight" is not aimed towards them.

If someone could help me with either of those problems, it would be really appreciated

Thanks a lot, Mathieu.

EDIT

I've simplified my game to make it on time. However, I still have a major problem; the flashlight. I would like it to mask everything else except where it's actually aimed.

Still not able to make the collisions too.

http://ifile.it/xmhra7g

Sorry for being annoying with my questions. Thanks, Mathieu.


A good place to start would be reversing their direction when they hit a wall..

But it's going to require a little more math than that to get it going... For now around line 130 you have this:

function updatePosition(follower:MovieClip, target:MovieClip) {

below that add something like this.. multiplying the current direciton by -1 will reverse it for X and Y:

if (_root.environment.hitTest(follower._x, follower._y, true)) {
    follower.moveX = -follower.moveX;
    follower.moveY = -follower.moveY;
}

(Remember this is only going to work on the ones that don't start out touching the wall... if the initial coordinates of one of your triangle monsters is already inside the wall this will not work.. What you could do is check if the initial x and y is a valid hit test on the wall give it new coordinates, and keep doing so until it starts on the path.. )

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜