here is my code:
rem Landscape App
SetDisplayAspect( -1 )
AddVirtualJoystick(1,6,91,8)
AddVirtualButton (1,95,91,5)
rem Create Sprite
spr = createSprite(0)
setSpriteSize(spr,4,8)
setSpriteOffset(spr,2,4)
setSpritePositionByOffset(spr,50,50)
setSpritePhysicsOn(spr,2)
setSpritePhysicsCanRotate(spr,0)
boxman = spr
// Load ground Texture
img = LoadImage ("Texture.png")
ground = CreateSprite(img)
setSpriteAnimation(ground,128,128,2)
SetSpriteVisible(ground,0)
do
Print ("Joystick X: " + str(GetVirtualJoystickX(1)))
Print ("Joystick Y: " + str(GetVirtualJoystickY(1)))
SetSpritePhysicsVelocity (boxman, GetVirtualJoystickX(1)*20, GetSpritePhysicsVelocityY(boxman))
jump = GetVirtualButtonPressed(1)
if jump>0
if (Press = 0)
setSpritePhysicsVelocity(boxman,getSpritePhysicsVelocityX(boxman),-jump*60)
Press = 1
endif
endif
if getSpritePhysicsVelocityY(boxman) = 0 Then Press = 0
Print (cspr)
Sync()
loop