to do this all you need is trig...
M
............./|
.........../..|
........./....|
......./......|Y
...../........|
O /A_____|
X
take this badly drawn ascii triangle were 'O' is the origin of the shot 'M' where the aimer/mouse is and 'A' is the angle.
what you need to do is find 'A'
to do this you use
atan2(Y,X)
(or if its based of a characters rotation use the characters rotation as A)
then to get the projectile to move:
Math.sin(iAngle * (Math.PI/180))
this will give you the amount you need to increment the x value by every frame
Math.sin(iAngle * (Math.PI/180))
for the y increment:
Math.cosn(iAngle * (Math.PI/180)) *-1
so all up (pretend that this is based off char rotation and the
Code:
addEventListener(Event.ENTER_FRAME,eFrame)
addEventListener(MouseEvent.MOUSE_DOWN, shootOn);
function eFrame(evt:Event){
projectile .x+=xInc
projectile .y+=yInc
}
function shootOn(evt.MouseEvent){
var xInc:Number = Math.sin(charRotation* (Math.PI/180))
var yInc:Number = Math.cos(charRotation* (Math.PI/180)) * 1;
}
of course you realise that you will need to do that properly but thats the general gist of that.
for other things like gravity just do somthing like
for bouncing projectlies
Code:
if (projectile.y == ground){
yInc = -yInc * bounceDecay // 0.4 or something like that
}
i hope that helps i will once again say that it is all really rough so dont dig into me for that its just there to give you an idea of what to do