Quote: "i thought the force had to be a "line" through the sprite"
it means that the force vector is parallel with the line from the centre of the sprite to the force position. other wise the force will cause body rotation.
I wrote this example on two sprites:
1, rocket: offset and body mass is in the top centre of the sprite image.
2, saw: offset and body mass is in the centre of the sprite image.
notice that no rotation happen when you balance your sprite inner physics.
download the full file example I made for you.
SetDisplayAspect( 4.0/3.0 )
setclearcolor(200,200,0)
setbordercolor(125,0,0)
setvirtualresolution(640,480)
#constant circle 1
#constant polygon 3
#constant dynamic 2
setphysicsgravity(0,0)
saw = createsprite(loadimage("saw.png",0))
setspritepositionbyoffset(saw,500,60)
setspritecolor(saw,198,50,20,255)
setspriteshape(saw,circle)
setspritephysicson(saw,dynamic)
setspritephysicsangulardamping(saw,.6)
setspritephysicsrestitution(saw,.5)
rocket = createsprite(loadimage("triangle.png",0))
setspriteoffset(rocket,getspritewidth(rocket)/2.0,0)
setspritepositionbyoffset(rocket,320,400)
setspriteshape(rocket,polygon)
setspritephysicson(rocket,dynamic)
setspritephysicsangulardamping(rocket,.6)
setspritephysicsrestitution(rocket,.5)
addvirtualjoystick(1,550,400,90)
setvirtualjoystickimageinner(1,saw)
addvirtualjoystick(2,100,400,90)
setvirtualjoystickimageinner(2,rocket)
text1 = createtext("JOYSTICK") : text2 = createtext("JOYSTICK")
settextsize(text1,24) : settextsize(text2,24)
settextalignment(text1,1) : settextalignment(text2,1)
settextposition(text1,100,320) : settextposition(text2,550,320)
rem A Wizard Did It!
do
sawforce_x# = getvirtualjoystickx(1) * getspritephysicsmass(saw) *100
sawforce_y# = getvirtualjoysticky(1) * getspritephysicsmass(saw) *100
saw_x# = getspritexbyoffset(saw)
saw_y# = getspriteybyoffset(saw)
setspritephysicsforce(saw, saw_x#, saw_y#, sawforce_x#, sawforce_y#)
rocketforce_x# = getvirtualjoystickx(2) * getspritephysicsmass(rocket) *50
rocketforce_y# = getvirtualjoysticky(2) * getspritephysicsmass(rocket) *50
rocket_x# = getspritexbyoffset(rocket)
rocket_y# = getspriteybyoffset(rocket)
setspritephysicsforce(rocket, rocket_x#, rocket_y#, rocketforce_x#, rocketforce_y#)
Sync()
loop