I understand your code Scraggle and is not Slut.
but your code don't work in my project.
this is my code. I add your code after "do---loop" and add
"initDisplay( VIRTUAL, 1280, 800 )" at first line of my project. but when I export it to my phone don't change anything.
initDisplay( VIRTUAL, 1280, 800 )
// Add Virtual Joystick
keyboard = GetKeyboardExists()
if keyboard <> 1
AddVirtualJoystick(1,105,695,150)
endif
SetphysicsGravity (0,1000)
// Global Variables
global state = 0
global playspr = 0
// Load Image Animatios
idleImage = LoadImage ("idle.png")
walkImage = LoadImage("walk.png")
climbupImage = LoadImage("climb.png")
// Create Player Sprite
spr = CreateSprite(idleImage)
SetSpritePosition (spr,40,105)
setSpriteSize(spr,112,-1)
SetSpriteShape (spr,3)
setSpritePhysicsOn(spr,2)
setSpritePhysicsCanRotate(spr,0)
SetSpriteDepth (spr, 0)
spr_weight = GetSpritePhysicsMass (spr)*2000
SetSpriteAnimation ( spr, 170, 170, 4 )
PlaySprite ( spr, 10 , 1, 1, 4 )
// Create Floor1 Sprite
Floor1 = CreateSprite(LoadImage("floor1.png"))
setSpritePhysicsOn(Floor1,1)
w# = GetSpriteWidth(Floor1)
h# = GetSpriteHeight(Floor1)
SetSpriteShapeBox(Floor1, -w#/2, -h#/2, 0, h#/2, 0)
AddSpriteShapeBox (Floor1, w#/8, -h#/4, 0, h#/2, 0)
AddSpriteShapeBox(Floor1, w#/8, 0, w#/4, h#/2, 0)
SetSpriteAnimation(Floor1,256,256,2)
SetSpriteFrame (Floor1,2)
SetSpriteDepth (Floor1,0)
SetSpritePosition(Floor1,0,545)
// Create invible Sprite
HideSpr = CreateSprite(0)
SetSpriteVisible (HideSpr,0)
global dim CloneSpr[33]
for i = 1 to 32
if GetSpriteExists (CloneSpr[i]) = 0 then CloneSpr[i] = CloneSprite(HideSpr)
SetSpriteVisible (CloneSpr[i],1)
Select i
case 1:
SetSpriteImage (CloneSpr[1],LoadImage("floor2.png"))
SetSpritePosition (CloneSpr[1],128,289)
SetSpriteSize (CloneSpr[1],512,512)
SetSpriteDepth (CloneSpr[1],1)
endcase
case 2:
SetSpriteImage(CloneSpr[2],LoadImage("floor3.png"))
setSpritePhysicsOn(CloneSpr[2],1)
SetSpritePosition(CloneSpr[2],385,545)
SetSpriteSize (CloneSpr[2],512,256)
SetSpriteDepth (CloneSpr[2],0)
w2# = GetSpriteWidth(CloneSpr[2])
h2# = GetSpriteHeight(CloneSpr[2])
SetSpriteShapeBox(CloneSpr[2], -w2#/4, -h2#/4, -w2#/2, h2#/2 ,0)
point = 6
AddSpriteShapePolygon(CloneSpr[2], point, 0, -w2#/4, -h2#/4)
AddSpriteShapePolygon(CloneSpr[2], point, 1, -w2#/8, -h2#/2)
AddSpriteShapePolygon(CloneSpr[2], point, 2, w2#/8, -h2#/2)
AddSpriteShapePolygon(CloneSpr[2], point, 3, w2#/4, -h2#/4)
AddSpriteShapePolygon(CloneSpr[2], point, 4, w2#/4, h2#/2)
AddSpriteShapePolygon(CloneSpr[2], point, 5, -w2#/4, h2#/2)
point = 4
AddSpriteShapePolygon(CloneSpr[2], point, 0, w2#/4, -h2#/4)
AddSpriteShapePolygon(CloneSpr[2], point, 1, w2#/2, 0)
AddSpriteShapePolygon(CloneSpr[2], point, 2, w2#/2, h2#/2)
AddSpriteShapePolygon(CloneSpr[2], point, 3, w2#/4, h2#/2)
endcase
case 3:
SetSpriteImage(CloneSpr[3],LoadImage("floor4.png"))
SetSpritePosition(CloneSpr[3],770,482)
SetSpriteSize (CloneSpr[3],320,320)
endcase
case 4:
SetSpriteImage(CloneSpr[4],LoadImage("floor5.png"))
SetSpritePosition(CloneSpr[4],1027,610)
SetSpriteSize (CloneSpr[4],256,192)
SetSpriteDepth (CloneSpr[4],0)
setSpritePhysicsOn(CloneSpr[4],1)
endcase
case 5:
SetSpriteImage(CloneSpr[5],LoadImage("floor6.png"))
SetSpritePosition(CloneSpr[5],-64,220)
SetSpriteSize (CloneSpr[5],256,54)
SetSpriteDepth (CloneSpr[5],0)
SetSpritePhysicsOn(CloneSpr[5],1)
SetSpriteShape (CloneSpr[5],3)
endcase
case 6:
SetSpriteImage(CloneSpr[6],LoadImage("rail.png"))
SetSpritePosition(CloneSpr[6],192,222)
SetSpriteSize (CloneSpr[6],638,29)
SetSpriteDepth (CloneSpr[6],0)
SetSpritePhysicsOn(CloneSpr[6],1)
SetSpriteShape (CloneSpr[6],3)
endcase
case 7:
SetSpriteImage(CloneSpr[7],LoadImage("floor7.png"))
SetSpritePosition(CloneSpr[7],829,220)
SetSpriteSize (CloneSpr[7],257,54)
SetSpriteDepth (CloneSpr[7],0)
SetSpritePhysicsOn(CloneSpr[7],1)
SetSpriteShape (CloneSpr[7],3)
endcase
case 8:
SetSpriteImage(CloneSpr[8],LoadImage("wall-1.png"))
SetSpritePosition(CloneSpr[8],0,0)
SetSpriteSize (CloneSpr[8],576,128)
SetSpriteDepth (CloneSpr[8],1)
endcase
case 9:
SetSpriteImage(CloneSpr[9],LoadImage("wall-2.png"))
SetSpritePosition(CloneSpr[9],577,0)
SetSpriteSize (CloneSpr[9],704,128)
SetSpriteDepth (CloneSpr[9],1)
endcase
case 10:
SetSpriteImage(CloneSpr[10],LoadImage("door.png"))
SetSpritePosition(CloneSpr[10],30,87)
SetSpriteDepth (CloneSpr[10],1)
SetSpriteAnimation(CloneSpr[10],120,134,2)
SetSpriteFrame (CloneSpr[10],2)
endcase
case 11:
SetSpriteImage(CloneSpr[11],LoadImage("lamp.png"))
SetSpritePosition(CloneSpr[11],140,37)
SetSpriteSize (CloneSpr[11],110,66)
SetSpriteDepth (CloneSpr[11],1)
endcase
case 12: // large lamp
SetSpriteImage(CloneSpr[12],LoadImage("mul.png"))
SetSpritePosition(CloneSpr[12],600,15)
SetSpriteSize (CloneSpr[12],110,106)
SetSpriteAnimation(CloneSpr[12],128,128,4)
SetSpriteFrame (CloneSpr[12],4)
SetSpriteDepth (CloneSpr[12],1)
endcase
case 13:
SetSpriteImage(CloneSpr[13],LoadImage("moving-body.png"))
SetSpritePosition(CloneSpr[13],212.5,183)
SetSpriteSize (CloneSpr[13],100,-1)
SetSpriteDepth (CloneSpr[13],0)
SetSpritePhysicsOn(CloneSpr[13],2)
SetSpriteShape (CloneSpr[13],3)
SetSpritePhysicsMass (CloneSpr[13],10000)
endcase
case 14:
SetSpriteImage(CloneSpr[14],LoadImage("wheel.png"))
SetSpritePositionByOffset(CloneSpr[14],230,205)
SetSpriteSize (CloneSpr[14],32,-1)
SetSpriteDepth (CloneSpr[14],0)
SetSpritePhysicsOn(CloneSpr[14],2)
SetSpriteShapeCircle (CloneSpr[14],0,0,10)
SetSpritePhysicsMass (CloneSpr[14],10000)
endcase
case 15:
SetSpriteImage(CloneSpr[15],LoadImage("wheel.png"))
SetSpritePositionByOffset(CloneSpr[15],295,205)
SetSpriteSize (CloneSpr[15],32,-1)
SetSpriteDepth (CloneSpr[15],0)
SetSpritePhysicsOn(CloneSpr[15],2)
SetSpriteShapeCircle (CloneSpr[15],0,0,10)
SetSpritePhysicsMass (CloneSpr[15],10000)
endcase
case 16:
SetSpriteImage(CloneSpr[16],LoadImage("fire.png"))
SetSpritePosition(CloneSpr[16],1000,60)
SetSpriteSize (CloneSpr[16],128,64)
SetSpriteDepth (CloneSpr[16],1)
SetSpriteAnimation (CloneSpr[16],128,64,4)
PlaySprite (CloneSpr[16],7,1,1,4)
endcase
case 17:
SetSpriteImage(CloneSpr[17],LoadImage("fire.png"))
SetSpritePosition(CloneSpr[17],10,290)
SetSpriteSize (CloneSpr[17],128,64)
SetSpriteDepth (CloneSpr[17],1)
SetSpriteAnimation (CloneSpr[17],128,64,4)
PlaySprite (CloneSpr[17],7,1,1,4)
endcase
case 18: // large lamp
SetSpriteImage(CloneSpr[18],LoadImage("mul.png"))
SetSpritePosition(CloneSpr[18],950,270)
SetSpriteSize (CloneSpr[18],110,106)
SetSpriteAnimation(CloneSpr[18],128,128,4)
SetSpriteFrame (CloneSpr[18],4)
SetSpriteDepth (CloneSpr[18],1)
endcase
case 19:
SetSpriteImage(CloneSpr[19],LoadImage("door.png"))
SetSpritePosition(CloneSpr[19],800,349)
SetSpriteDepth (CloneSpr[19],1)
SetSpriteAnimation(CloneSpr[19],120,134,2)
SetSpriteFrame (CloneSpr[19],1)
endcase
case 20:
SetSpriteImage(CloneSpr[20],LoadImage("dirt.png"))
SetSpritePosition(CloneSpr[20],900,392)
SetSpriteSize (CloneSpr[20],90,90)
SetSpriteDepth (CloneSpr[20],1)
SetSpriteAnimation(CloneSpr[20],128,128,4)
SetSpriteFrame (CloneSpr[20],2)
endcase
case 21:
SetSpriteImage(CloneSpr[21],LoadImage("dirt.png"))
SetSpritePosition(CloneSpr[21],640,354.5)
SetSpriteSize (CloneSpr[21],64,64)
SetSpriteDepth (CloneSpr[21],1)
SetSpriteAnimation(CloneSpr[21],128,128,4)
SetSpriteFrame (CloneSpr[21],1)
endcase
case 22:
SetSpriteImage(CloneSpr[22],LoadImage("lever.png"))
SetSpritePosition(CloneSpr[22],950,120)
SetSpriteSize (CloneSpr[22],100,100)
SetSpriteDepth (CloneSpr[22],1)
SetSpriteAnimation(CloneSpr[22],128,128,4)
endcase
case 23:
SetSpriteImage(CloneSpr[23],LoadImage("vertical-slider.png"))
SetSpritePositionByOffset(CloneSpr[23],1180,350)
SetSpriteSize (CloneSpr[23],45,350)
SetSpriteDepth (CloneSpr[23],1)
//SetSpritePhysicsOn (CloneSpr[23],1)
endcase
case 24:
SetSpriteImage(CloneSpr[24],LoadImage("vertical-moving.png"))
SetSpritePosition(CloneSpr[24],1115,420)
SetSpriteSize (CloneSpr[24],128,64)
SetSpriteDepth (CloneSpr[24],1)
endcase
case 25:
SetSpriteImage(CloneSpr[25],LoadImage("crystal.png"))
SetSpritePosition(CloneSpr[25],840,177)
SetSpriteSize (CloneSpr[25],50,50)
SetSpriteDepth (CloneSpr[25],1)
SetSpriteAnimation(CloneSpr[25],64,64,2)
SetSpriteFrame (CloneSpr[25],1)
endcase
case 26:
SetSpriteImage(CloneSpr[26],LoadImage("chain.png"))
SetSpritePosition(CloneSpr[26],960,585)
SetSpriteSize (CloneSpr[26],16,64)
//SetSpritePhysicsOn(CloneSpr[26],1)
endcase
case 27:
SetSpriteImage(CloneSpr[27],LoadImage("box.png"))
SetSpritePositionByOffset(CloneSpr[27],968,670)
SetSpriteSize (CloneSpr[27],57,57)
SetSpritePhysicsOn(CloneSpr[27],1)
SetSpritePhysicsCanRotate (CloneSpr[27],0)
endcase
case 28: // Barrel
SetSpriteImage(CloneSpr[28],LoadImage("mul.png"))
SetSpritePositionByOffset(CloneSpr[28],32,513)
SetSpriteSize (CloneSpr[28],70,70)
SetSpritePhysicsOn(CloneSpr[28],1)
SetSpriteAnimation(CloneSpr[28],128,128,4)
SetSpriteFrame (CloneSpr[28],3)
SetSpriteDepth(CloneSpr[28],0)
endcase
case 29:
SetSpriteImage(CloneSpr[29],LoadImage("ladder.png"))
SetSpritePositionByOffset(CloneSpr[29],490,490)
SetSpriteSize (CloneSpr[29],50,-1)
SetSpriteDepth(CloneSpr[29],1)
endcase
case 30:
SetSpriteImage(CloneSpr[30],LoadImage("floor8.png"))
SetSpritePosition(CloneSpr[30],0,200)
SetSpriteSize (CloneSpr[30],1024,-1)
endcase
case 31: // Floor 9
SetSpriteImage(CloneSpr[31],LoadImage("mul.png"))
SetSpritePosition(CloneSpr[31],0,457)
SetSpriteSize (CloneSpr[31],128,-1)
SetSpriteAnimation(CloneSpr[31],128,128,4)
SetSpriteFrame (CloneSpr[31],1)
endcase
case 32: // Floor 10
SetSpriteImage(CloneSpr[32],LoadImage("floor1.png"))
SetSpritePosition(CloneSpr[32],1024.12,202)
SetSpriteSize (CloneSpr[32],254,-1)
SetSpriteAnimation(CloneSpr[32],256,256,2)
SetSpriteFrame (CloneSpr[32],1)
endcase
endselect
Next i
// Joint wheels to body
CreateRevoluteJoint ( 1, CloneSpr[13], CloneSpr[14], 230, 205, 0 )
CreateRevoluteJoint ( 2, CloneSpr[13], CloneSpr[15], 295, 205, 0 )
// Joint Chain to Box
//CreateRevoluteJoint ( 3, CloneSpr[26], CloneSpr[27], 966, 645, 0 )
// Create Diamond========================================================================
HideSpr2 = CreateSprite(LoadImage("diamond.png"))
SetSpriteVisible (HideSpr2,0)
global dim Diamond [30]
for n = 1 to 6
if GetSpriteExists(Diamond[n]) = 0 then Diamond[n] = CloneSprite(HideSpr2)
SetSpriteVisible(Diamond[n],1)
SetSpriteSize(Diamond[n],32,-1)
SetSpriteDepth(Diamond[n],0)
SetSpriteAnimation(Diamond[n],64,64,2)
SetSpriteFrame(Diamond[n],2)
SetSpritePosition (Diamond[n],400+n*25, 105)
for m = 7 to 12
if GetSpriteExists (Diamond[m]) = 0 then Diamond[m] = CloneSprite(HideSpr2)
SetSpriteVisible(Diamond[m],1)
SetSpriteSize(Diamond[m],32,-1)
SetSpriteDepth(Diamond[m],0)
SetSpriteAnimation(Diamond[m],64,64,2)
SetSpriteFrame(Diamond[m],2)
SetSpritePosition (Diamond[m],400+(m-6)*25, 130)
Next m
Next n
for o = 13 to 18
if GetSpriteExists (Diamond[o]) = 0 then Diamond[o] = CloneSprite(HideSpr2)
SetSpriteVisible(Diamond[o],1)
SetSpriteSize(Diamond[o],32,-1)
SetSpriteDepth(Diamond[o],0)
SetSpriteAnimation(Diamond[o],64,64,2)
SetSpriteFrame(Diamond[o],1)
SetSpritePosition (Diamond[o],200+(o-12)*25, 500)
for p = 19 to 24
if GetSpriteExists(Diamond[p]) = 0 then Diamond[p] = CloneSprite(HideSpr2)
SetSpriteVisible(Diamond[p],1)
SetSpriteSize(Diamond[p],32,-1)
SetSpriteDepth(Diamond[p],0)
SetSpriteAnimation(Diamond[p],64,64,2)
SetSpriteFrame(Diamond[p],1)
SetSpritePosition (Diamond[p],200+(p-18)*25, 525)
Next p
Next o
for q = 25 to 30
if GetSpriteExists(Diamond[q]) = 0 then Diamond[q] = CloneSprite(HideSpr2)
SetSpriteVisible(Diamond[q],1)
SetSpriteSize(Diamond[q],32,-1)
SetSpriteDepth(Diamond[q],0)
SetSpriteAnimation(Diamond[q],64,64,2)
SetSpriteFrame(Diamond[q],1)
SetSpritePosition (Diamond[q],850+(q-24)*25, 525)
Next q
// END===================================================================================
do
//Pickup Diamond ====================================================
global dim diacollide [30]
for j = 1 to 30
diacollide[j] = GetSpriteCollision(spr,Diamond[j])
if diacollide[j] = 1 then SetSpriteVisible (Diamond[j],0)
Next j
//END ===============================================================
// lever & Elevator Control =================================================================================
px# = GetPointerX()
py# = GetPointerY()
mousehit = GetSpriteHitTest (CloneSpr[22],ScreenToWorldX(px#),ScreenToWorldY(py#))
if mousehit = 1
if GetPointerPressed () = 1
if playspr = 0 then playspr = 1
endif
endif
if playspr = 1
playspr = 2
if GetSpritePlaying(CloneSpr[22]) = 0
PlaySprite(CloneSpr[22],10,0,1,4)
endif
endif
// Move Elevator
if playspr = 2
if GetSpritePlaying(CloneSpr[22]) = 0
SetSpritePhysicsDelete(CloneSpr[27])
SetSpritePhysicsOn(CloneSpr[27],2)
SetSpritePhysicsCanRotate(CloneSpr[27], 0)
if GetSpriteY(CloneSpr[24]) > 215 and verticalmoving = 0 then verticalmoving = 1
endif
endif
if verticalmoving = 1
SetSpritePhysicsOn (CloneSpr[24],2)
SetSpritePhysicsCanRotate(CloneSpr[24], 0)
SetSpriteShape(CloneSpr[24],3)
SetSpritePhysicsMass (CloneSpr[24],1000000)
SetSpritePosition (CloneSpr[24],GetSpriteX(CloneSpr[24]),GetSpriteY(CloneSpr[24])-0.6)
endif
if GetSpriteY(CloneSpr[24]) <= 215 and (verticalmoving = 1 or verticalmoving = 3) then verticalmoving = 2
if verticalmoving = 2
SetSpritePosition(CloneSpr[24], GetSpriteX(CloneSpr[24]),GetSpriteY(CloneSpr[24])+0.25)
endif
if GetSpriteY(CloneSpr[24]) >= 420 and verticalmoving = 2 then verticalmoving = 3
if verticalmoving = 3
SetSpritePosition (CloneSpr[24],GetSpriteX(CloneSpr[24]),GetSpriteY(CloneSpr[24])-0.6)
endif
// END =====================================================================================
// Move Gari ================================================================
if GetSpriteX(CloneSpr[14]) < 785 and movestate = 0 then movestate = 1
if movestate = 1
SetSpritePhysicsVelocity (CloneSpr[14],40,GetSpritePhysicsVelocityY(CloneSpr[14]))
SetSpritePhysicsVelocity (CloneSpr[15],40,GetSpritePhysicsVelocityY(CloneSpr[15]))
endif
if GetSpriteX(CloneSpr[15]) >= 785 and (movestate = 1 or movestate = 3) then movestate = 2
if movestate = 2
SetSpritePhysicsVelocity (CloneSpr[14],-40,GetSpritePhysicsVelocityY(CloneSpr[14]))
SetSpritePhysicsVelocity (CloneSpr[15],-40,GetSpritePhysicsVelocityY(CloneSpr[15]))
endif
if GetSpriteX(CloneSpr[14]) <= 210 and movestate = 2 then movestate = 3
if movestate = 3
SetSpritePhysicsVelocity (CloneSpr[14],40,GetSpritePhysicsVelocityY(CloneSpr[14]))
SetSpritePhysicsVelocity (CloneSpr[15],40,GetSpritePhysicsVelocityY(CloneSpr[15]))
endif
//END ============================================================================
// Move the spr to left-right and UP-Down From Ladder ====================================================
if keyboard = 1
if GetRawKeyState (39) = 1
SetSpriteFlip (spr,0,0)
SetSpritePhysicsVelocity (spr, 200, GetSpritePhysicsVelocityY(spr))
if state = 0 then state = 1
elseif GetRawKeyState (37) = 1
SetSpriteFlip (spr,1,0)
SetSpritePhysicsVelocity (spr, -200, GetSpritePhysicsVelocityY(spr))
if state = 0 then state = 1
else
if state = 2
state = 0
SetSpritePhysicsVelocity (spr, 0, GetSpritePhysicsVelocityY(spr))
SetSpriteImage(spr , idleImage)
SetSpriteAnimation ( spr, 170, 170, 4 )
PlaySprite ( spr, 10, 1)
endif
// Move The Player climb up Ladder
sprY = GetSpriteY(spr)
laddercollide = getSpriteCollision (spr,CloneSpr[29])
if laddercollide = 1
SetSpritePhysicsForce( spr, GetSpriteX(spr), GetSpriteY(spr), 0, spr_weight*-1)
if GetRawKeyState(38) = 1
SetSpritePhysicsVelocity(spr,GetSpritePhysicsVelocityX(spr),-80)
else if GetRawKeyState(40) = 1
SetSpritePhysicsVelocity(spr,GetSpritePhysicsVelocityX(spr),80)
else
SetSpritePhysicsVelocity(spr,GetSpritePhysicsVelocityX(spr),0)
endif
endif
endif
endif
// END =================================================================================
if GetRawKeyPressed (32) = 1
SetSpritePhysicsVelocity (spr,GetSpritePhysicsVelocityX(spr),-400)
endif
endif
//END ========================================================================================
// Control Virtual Joystick===================================================================================
if keyboard <> 1
if GetVirtualJoystickX(1) > 0.1
SetSpriteFlip (spr,0,0)
SetSpritePhysicsVelocity (spr, GetVirtualJoystickX(1)*200, GetSpritePhysicsVelocityY(spr))
if state = 0 then state = 1
elseif GetVirtualJoystickX(1) < -0.1
SetSpriteFlip (spr,1,0)
SetSpritePhysicsVelocity (spr, GetVirtualJoystickX(1)*200, GetSpritePhysicsVelocityY(spr))
if state = 0 then state = 1
else
if state = 2
state = 0
SetSpritePhysicsVelocity (spr, 0, GetSpritePhysicsVelocityY(spr))
SetSpriteImage(spr , idleImage)
SetSpriteAnimation ( spr, 170, 170, 4 )
PlaySprite ( spr, 10, 1)
endif
endif
endif
//END ========================================================================================================
// Change Animation to walk
if state = 1
state = 2
SetSpriteImage(spr , walkImage)
SetSpriteAnimation(spr,170,170,12)
PlaySprite(spr,10,1,1,12)
endif
// Change Animation to Climb Up
if state = 3
state = 4
SetSpriteImage(spr , climbupImage)
SetSpriteAnimation (spr, 170,170,6)
PlaySprite(spr,10,1,1,6)
endif
Update2D(0) : Render2DFront() : Swap()
loop
// Create Display Function
function initDisplay(style as integer, width as integer, height as integer)
if style = PERCENTAGE
SetDisplayAspect(1)
else
SetVirtualResolution( width, height )
endif
global display as tDisplay
display.left = GetScreenBoundsLeft()
display.right = GetScreenBoundsRight()
display.top = GetScreenBoundsTop()
display.bottom = GetScreenBoundsBottom()
display.width = display.right-display.left
display.height = display.bottom-display.top
SetScissor(display.left,display.top,display.right,display.bottom)
endfunction
#constant VIRTUAL 0
#constant PERCENTAGE 1
type tDisplay
left as Integer
right as Integer
top as integer
bottom as integer
width as integer
height as integer
endtype
this your code that I Improve it for myself that could better understand.
I remove 4 box and create a Player that can move to left and right. but seem there is a invisible wall in top and bottom of screen.but when export it to my phone, there is no invisible wall at left and right.
initImages()
initDisplay( VIRTUAL, 1280, 800 )
//initDisplay( PERCENTAGE, 0, 0 )
SetPhysicsGravity(0,1000)
AddVirtualJoystick(1,1100,680,300)
// Player Sprite
spr = CreateSprite(0)
SetSpriteSize (spr,100,200)
SetSpritePhysicsON (spr,2)
SetSpriteDepth(spr, 0)
do
// Move Player
if GetVirtualJoystickX(1) > 0.1
SetSpritePhysicsVelocity (spr, GetVirtualJoystickX(1)*200, GetSpritePhysicsVelocityY(spr))
elseif GetVirtualJoystickX(1) < -0.1
SetSpritePhysicsVelocity (spr, GetVirtualJoystickX(1)*200, GetSpritePhysicsVelocityY(spr))
else
SetSpritePhysicsVelocity (spr, GetVirtualJoystickX(1), GetSpritePhysicsVelocityY(spr))
endif
sync()
loop
function initDisplay(style as integer, width as integer, height as integer)
if style = PERCENTAGE
SetDisplayAspect(1)
else
SetVirtualResolution( width, height )
endif
global display as tDisplay
display.left = GetScreenBoundsLeft()
display.right = GetScreenBoundsRight()
display.top = GetScreenBoundsTop()
display.bottom = GetScreenBoundsBottom()
display.width = display.right-display.left
display.height = display.bottom-display.top
SetScissor(display.left, display.top, display.right, display.bottom )
SetSpritePosition(sky, display.left, display.top)
SetSpriteSize(sky, display.width, display.height)
endfunction
function initImages()
global sky as integer
sky = CreateSprite( 0 )
SetSpriteColor (sky, 48,189,231,255)
SetSpritePosition(sky, display.left, display.top)
SetSpriteDepth(sky, 1)
endfunction
#constant VIRTUAL 0
#constant PERCENTAGE 1
type tDisplay
left as integer
right as integer
top as integer
bottom as integer
width as integer
height as integer
endtype