Hi.
already I create a topic for solve a Problem with climb ladder but don't solve it. Now I create new topic for solve this Problem.
in my previous topic
fly ball I learn how use setvirtualresolution and fix fly ball with set SetphysicsGravity (x,y),and thanks all that help me with explanation and examples.
now I want create a part of Professor Fizzwizzle game for familiar with Physics and other things.
my Problem is when I climb the ladder and come to top ladder, if try move up again my player jump on top of ladder. now I need your helps for fix this Problem.
this is my code:
rem Landscape App
SetVirtualResolution (1280,720)
// Create VirtualJoystick
AddVirtualJoystick(1,70,650,100)
rem Create Player Sprite
spr = createSprite(0)
SetSpritePosition (spr,250,300)
setSpriteSize(spr,50,-1)
setSpritePhysicsOn(spr,2)
setSpritePhysicsCanRotate(spr,0)
SetSpriteDepth (spr, 0)
Player = spr
// Load ground Texture
img = LoadImage ("Texture.png")
ground = CreateSprite(img)
setSpriteAnimation(ground,128,128,2)
SetSpriteVisible(ground,0)
// Create Ladder
imgladder = LoadImage ("ladder.png")
ladder = CreateSprite (imgladder)
SetSpritePosition (ladder,400,360)
SetSpriteSize (ladder, 100, -1)
setspritephysicson(ladder,1)
SetSpritePhysicsIsSensor( ladder, 1 )
SetphysicsGravity (0,700)
do
// Create Floor Sprite
cspr = 100
for n = 0 to 12
if getspriteexists(cspr)=0 then clonesprite(cspr,ground)
setspritephysicson(cspr,1)
setspriteframe(cspr,2)
setspritevisible(cspr,1)
SetSpritePosition (cspr, n*100, 620)
SetSpriteSize (cspr, 100,-1)
inc cspr
next n
// Move the Player to left and right
SetSpritePhysicsVelocity (Player, GetVirtualJoystickX(1)*140, GetSpritePhysicsVelocityY(Player))
// Check Player Collide with ladder
collide = GetPhysicsCollision (ladder, spr)
if (collide) = 1 then Print ("Collide")
// Climb UP ladder
if collide = 1
if (GetVirtualJoystickY (1) < 0 and up = 0)
Print ("UP")
SetSpritePhysicsVelocity (spr, GetSpritePhysicsVelocityX (spr), GetVirtualJoystickY(1) * 90)
SetPhysicsGravity (0,0)
// Climp Down ladder
else
if (GetVirtualJoystickY (1) > 0 and GetSpriteY(spr) < 569 )
Print ("Down")
SetSpritePhysicsVelocity (spr, GetSpritePhysicsVelocityX(spr), GetVirtualJoystickY (1) * 90)
SetPhysicsGravity (0,0)
else
SetSpritePhysicsVelocity(spr, getSpritePhysicsVelocityX(spr), 0)
endif
endif
endif
if collide = 0
SetPhysicsGravity (0,700)
else
SetPhysicsGravity (0,0)
endif
Print ("Joystick X: " + str(GetVirtualJoystickX(1)))
Print ("Joystick Y: " + str(GetVirtualJoystickY(1)))
Print ("" + str (GetspriteY(spr)))
Sync()
loop