I am making a Top Down Shooter in Flash CS4 using AS3.
When I shoot the bullets. I have set its starting position to be player.x and player.y. But that is where the player movieclip's "head" is at. I want it to be created from the place where the Gun is.
I made another movieclip inside of Player movieclip called "NewShootingPoint" and positioned it where the gun is.
I can't find any proper localToGlobal references to advice me. I know that localToGlobal converts a movieclip's local position to global position. But how do I do that?
I tried this: (New Code)
package {
import flash.display.MovieClip;
import flash.geom.Point;
import flash.display.Stage;
import flash.events.MouseEvent;
import flash.events.Event;
public class Main extends MovieClip {
//var myPoint : Point = new Point(340.1, 232.2);
var player : Player = new Player;
var origin : Gun = new Gun();
var bullet : Bullet = new Bullet();
public function Main() {
stage.addEventListener(MouseEvent.MOUSE_DOWN, onMouseDownHandler);
player.x = stage.stageWidth/2;
player.y = stage.stageHeight/2;
stage.addChild(player);
}
function onMouseDownHandler(e:Event) {
// I want this to happen.
bullet.x = origin.x;
bullet.y = origin.y;
// But it's still stuck at (0,0)
stage.addChild(bullet);
bullet.addEventListener(Event.ENTER_FRAME, thingy);
}
function thingy(e:Event) {
bullet.x += 10;
bullet.y += 10;
}
}
}
Yes. I know I should use classes. I'll do that later. Please advice for this!