PDA

View Full Version : Game help: Bullet


yopug
07-30-2007, 01:18 PM
alright, well i have a mc titled 'char' that moves around with the arrow keys. When the space bar is pressed, a gunshot is fired from 'char'. I put this code on the bullet_mc:

onClipEvent(enterFrame){
if(Key.isDown(32)){
this._y = _root.char._y;
this._x = _root.char._x;
this.play();
}
}

However, the problem is, while the bullet is shot, if my character moves up or down, the bullet moves up or down as well. How do i keep it so the bullet goes straight?

evride
07-31-2007, 07:19 AM
thats because putting code on movieclips screws everything up. learn how to write code on the main timeline.

newblack
08-01-2007, 11:35 AM
it's because bullet_mc is a child of char- it inherits any transformations... it's not because "putting code on movieclips screws everything up"- although it's definitel frowned upon practice.

whizkid1990
08-01-2007, 10:08 PM
make the bullet reference the position of char once only.