# \[FMX\] \_rotation problem

**URL:** https://forum.kirupa.com/t/fmx--rotation-problem/21177
**Category:** flash
**Created:** [May 18, 2003, 3:56pm UTC](https://forum.kirupa.com/t/fmx--rotation-problem/21177 "2003-05-18T15:56:12Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![RuZ](https://avatars.discourse-cdn.com/v4/letter/r/48db29/32.png) [@RuZ](https://forum.kirupa.com/u/RuZ)
#### Post date: [May 18, 2003, 3:56pm UTC](https://forum.kirupa.com/t/fmx--rotation-problem/21177/1 "2003-05-18T15:56:12Z")

</div>

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](http://www.rus.lico.nl/flash/vrienden.swf)  
shoot to the bottom right corner to see what i mean.

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [May 18, 2003, 6:08pm UTC](https://forum.kirupa.com/t/fmx--rotation-problem/21177/2 "2003-05-18T18:08:13Z")

</div>

with this code:

```auto
_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.

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [May 19, 2003, 11:22am UTC](https://forum.kirupa.com/t/fmx--rotation-problem/21177/3 "2003-05-19T11:22:10Z")

</div>

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
