I've come up with a little demo program:
`use w and s to angle canon and press space to shoot the canon ball
setVirtualResolution(800,480)
`create a canon
canon_spr = createSprite(0)
setSpriteSize(canon_spr,30,10)
setSpriteOffset(canon_spr,0,5)
setSpritePositionByOffset(canon_spr,10,300)
`create a canon ball
ball_spr = createSprite(0)
setSpriteSize(ball_spr,8,8)
setSpriteOffset(ball_spr,4,4)
setSpritePhysicsOn(ball_spr,2)
setSpritePhysicsMass(ball_spr,10)
`starting variables
canon_angle# = 315.0
ball_initial_speed# = 200
`set up physics
setPhysicsGravity(0,100)
do
`angle the canon
canon_angle# = canon_angle# + getJoystickY()
if canon_angle# < 270.0 then canon_angle# = 270.0
if canon_angle# > 360.0 then canon_angle# = 360.0
setSpriteAngle(canon_spr,canon_angle#)
`press space to fire the canon ball
if getButtonPressed(1) = 1
setSpritePositionByOffset(ball_spr, 10,300)
x_velocity# = ball_initial_speed#*cos(canon_angle#)
y_velocity# = ball_initial_speed#*sin(canon_angle#)
setSpritePhysicsVelocity(ball_spr,x_velocity#,y_velocity#)
endif
Sync()
loop
The values you want to play around with are setPhysicsGravity and the variable ball_initial_speed#.
Low values of gravity and ball_initial_speed# with give a light, floaty trajectory. Higher values of gravity and ball_initial_speed# will give a faster trajectory. The trick with a game it is to juggle the two value until you get something you're happy with.
A low initial speed and high gravity will cause the ball to drop but not go very far horizontally.
A high initial speed and low gravity will cause the ball to go in a straighter line.
In this example, changing the mass of the canon ball won't effect the trajectory as I'm just setting the ball's velocity. If you used a impulse force then the mass would effect the initial velocity of the ball as the impulse force would have more to push against (hope that makes sense).
Restitution will simulate air resistance, i.e. it will slow the ball down, but it won't simulate wind (i.e. the wind could cause the ball to move back toward the canon).
There's a whole bunch of other things you can play about with depending on what the canon ball is hitting but I'll leave that for now.
One other thing, this thread should have gone on the general AppGameKit board as this board is just for Android related issues, and you probably would've got more responses. I expect if you email or PM a mod they'll move it for you.
Hope this helps.