I found a basic example of how to create something that’ll shoot an object and create an arc based on an angle. I added a power Bar to it, but I noticed something bad about it.
The way it works the higher the speed is the further it goes and the faster it moves across the screen. This doesn’t give me enough control. Because essentially I want fast moving projectiles but I want to also be able to shoot both near and far.
With this current system that’s an impossibility… Can anyone shed some light on how I can do this better? Here’s the current way it’s being done (important parts):
bullet = new Bullet;
this.stage.addChild(bullet);
bullet.speed = 1 + powerBar.scaleX * 20;
powerBar.scaleX = 0;
bullet.xStep = bullet.speed*Math.cos((-weapon.rotation)*Math.PI/180);
bullet.yStep = bullet.speed*Math.sin((-weapon.rotation)*Math.PI/180);
bullet.addEventListener(Event.ENTER_FRAME, moveBullet);
//....
private function moveBullet(e:Event):void
{
e.target.x += e.target.xStep/(e.target.speed/3);
e.target.y -= e.target.yStep/(e.target.speed/3);
e.target.yStep -= gravity/30;
if(e.target.y > weapon.y)
{
e.target.removeEventListener(Event.ENTER_FRAME, moveBullet);
e.target.parent.removeChild(e.target);
}
}
Any help is appreciated.