Hi, could anyone help me please? I think I'm doing something fundamentally wrong. Whenever I put the code to control the player in the main loop it works fine but when I do it as a function I get the error "Sprite 0 does not exist at line 40" (Line 40: setSpritePhysicsVelocity(faceman,GetVirtualJoystickX(1)*30, - getSpritePhysicsVelocityY(faceman))
Thanks for your help,
rem Landscape App
SetDisplayAspect( 4.0/3.0 )
AddVirtualJoystick(1,10,88,12)
rem Create Player
create_player()
rem A Wizard Did It!
do
joystick_pos()
player_control()
Sync()
loop
Function joystick_pos()
Print("Joystick X:" + str(GetVirtualJoystickX(1)))
Print("Joystick Y:" + str(GetVirtualJoystickY(1)))
EndFunction
Function create_player()
spr = createSprite(0)
setSpriteSize(spr,4,8)
setSpriteOffset(spr,2,4)
setSpritePositionByOffset(spr,50,96)
setSpritePhysicsOn(spr,2)
setSpritePhysicsCanRotate(spr,0)
faceman = spr
EndFunction
Function player_control()
setSpritePhysicsVelocity(faceman,GetVirtualJoystickX(1)*30, - getSpritePhysicsVelocityY(faceman))
EndFunction