# [FMX] _rotation problem

Hi,

Ive made a little game with a guy that can walk across the screen and is able to shoot bullets. The function for the bullet looks like this :

function launchBullet () {
bips = _root.master.ventje.arm.kogelhier; // place where the bullet should start
var clipBips = {x:bips._x, y:bips._y};
bips._parent.localToGlobal(clipBips);
_root.bullet._x = clipBips.x;
_root.bullet._y = clipBips.y;
_root.bullet.deltax = clipBips.x;
_root.bullet.deltay = clipBips.y;
shipangle = _rotation;
shipangleinradians = shipangle*Math.PI/180;
_root.bullet.deltax = Math.cos(shipangleinradians)*20;
_root.bullet.deltay = Math.sin(shipangleinradians)*20;
}

in the bullet actions i have placed this code :

onClipEvent (enterFrame) {
_x += deltax;
_y += deltay;
if (_x<-20) {
_root.kogelmag = “ja”;
_x = -20;
_y = -20;
deltax = -20;
deltay = -20;
} else if (_x>570) {
_root.kogelmag = “ja”;
_x = -20;
_y = -20;
deltax = -20;
deltay = -20;
}
if (_y<-20) {
_root.kogelmag = “ja”;
_x = -20;
_y = -20;
deltax = -20;
deltay = -20;
} else if (_y>420) {
_root.kogelmag = “ja”;
_x = -20;
_y = -20;
deltax = -20;
deltay = -20;
}
}

The problem is that when i shoot to the right or down right the bullet starts not from the point where it should start (the kogelhier movieclip) but from the point where it outside the screen (x -20, y -20).

the SWF can be found at : http://www.rus.lico.nl/flash/vrienden.swf
shoot to the bottom right corner to see what i mean.

with this code:

``````_root.bullet.deltax = Math.cos(shipangleinradians)*20;
_root.bullet.deltay = Math.sin(shipangleinradians)*20;

``````

try adding to it the location of the person, since you want the bullet to shoot relative to where the gun is.

in the LaunchBullet() function i have this :

``````            bips = _root.master.ventje.arm.kogelhier;
var clipBips = {x:bips._x, y:bips._y};
bips._parent.localToGlobal(clipBips);
_root.bullet._x = clipBips.x;
_root.bullet._y = clipBips.y;
_root.bullet.deltax = clipBips.x;
_root.bullet.deltay = clipBips.y;
``````

wich gives the bullet the same _x and _y as the gun. so i already have the bullet positioned at the gun, but ONLY when i shoot to the right bottom it doesnt start from there