A little more feedback to help breakdown the parts of making an arrow, spear, etc. (There are many ways to do this)
To ‘fire’ the projectile, you need
- <x,y> starting position
- angle the projectile is initially facing
- magnitude of initial velocity
given the above, you would:
- create a display object using an image is facing up to represent 0-degrees (i.e. arrow pointing up == 0 degree)
- add a dynamic physics body to the display object
- rotate the display object to the ‘angle’ you selected.
- convert the angle (using 2D math) into a unit-length vector. i.e. represent the angle as a vector.
- scale the vector from the last step by the ‘magnitude’
- set the linear Velocity (obj:setLinearVelocit( vx, vy )) where vx and vy are the <x,y> values from the vector you just scaled.
At this point, the ‘arrow’ will start moving and will fly in an arc. The only part that is missing is, the arrow will NOT rotate to follow the current ‘arc’. You’ll need to add an enterFrame listener to the ‘arrow’ display object that will rotate the arrow based on the objects current velocity. This bit is tricky unless you’re familiar w/ 2D math. Horace is doing something like this in his code, but his enterFrame listener handles all of the movement too.
I hope this helps a little.
PS - Horace’s example is superior to my suggestion in the fact that he simulates ‘feather drag’ which really gives the arrow movement a nice ‘organic’ feel.