PDA

View Full Version : New to Kirupa, Need help with shooter.



Stilianos
June 20th, 2006, 01:22 AM
Hi im new to Kirupa, and i have looked through the site but havn't found much help on the (mouse angle shooter type game. I have the engine for the platforming but need help getting my character to follow the mouse.

The problem is that the code works if its on a movie clip. Not if its on a Mclip and in another Mclip.

Can you please share a code that works?


Thanx in advance

woad
June 20th, 2006, 01:27 AM
Ok so do you want your character to move in the direction of the mouse or shoot in that direction or rotate in that direction?

Stilianos
June 20th, 2006, 02:52 AM
Its ok i just figured it out thanx for your time though.

woad
June 20th, 2006, 03:08 AM
Yeah... No... problem

fabiopb
June 20th, 2006, 03:14 AM
:lol:

Stilianos
June 20th, 2006, 08:43 AM
Oops:-/
I think i did it wrong agian.:(
Umm if someone can fix this it would be great.
the problem is the crosshair makes the man fall through the ground.
Also (any) fixes to the script that you might want to improve its kk with me :) .

Stilianos
June 20th, 2006, 08:48 AM
Heres the fla.

woad
June 20th, 2006, 12:03 PM
I couldn't find the problem, but I did find a little cleaner code:

onClipEvent(enterFrame)
{
rx = _root.man.cross._x
ry = _root.man.cross._y
cx = _root.man.head._x;
cy = _root.man.head._y;
this._rotation = Math.atan2(ry-cy, rx-cx)*180/Math.PI;
}

That's for the head, something else I found was under the symbol definitions there were two head<head> options so maybe that helps.

SacrificialLamb
June 20th, 2006, 06:10 PM
make
ymax = this.getBounds(_root).yMax;
to
ymax = this.leg.getBounds(_root).yMax;

and in the man MC name the lowist pint legs.

the hit test stopped working coz the crosshair was in the man MC and you could move it under the ground so it would stop hitting and there for full

Stilianos
June 20th, 2006, 07:59 PM
Thanks alot:)

Stilianos
June 20th, 2006, 08:31 PM
Ok if your all not tyred of me already i have another problem:(
I have changed the _xscale and when ever i turn the cross hiar does too.
If you can help itl be great:)
Thanx in advance!

woad
June 20th, 2006, 08:39 PM
GOT IT!!!

Oh maybe if you make the target xscale -100

do this:

if (Key.isDown(Key.RIGHT) && !_root.ground.hitTest(xmax+speed, _y, true)) {
_x += speed;
_xscale = 100
this.cross._xscale = -100;
this.gotoAndStop(legs.run);
}
if (Key.isDown(Key.LEFT) && !_root.ground.hitTest(xmin-speed, _y, true)) {
_x -= speed;
_xscale = -100
this.cross._xscale = 100;
this.gotoAndStop(legs.run);
}

Huzzah!:pleased:

Stilianos
June 20th, 2006, 10:46 PM
LOL:)
I get it now thanx alot man cool!

woad
June 20th, 2006, 11:11 PM
=D