Trying to do a simple load sprite and display process. The image is shown, then it flickers and disappears. I'm sure it has to do with the FlipBuffers() but I can't seem to figure it out.
Code: Select all
InitMouse(#PB_Mouse_Locked)
InitSprite()
ExamineDesktops()
Height.l = DesktopHeight(0)
Width.l = DesktopWidth(0)
Debug(Height)
Debug(Width)
OpenScreen(Width, Height, DesktopDepth(0), "Test")
Dim SpriteList.l(100)
Global SpriteCount.l = 1
Procedure RenderFrame()
Global SpriteCount
Static x, y
ClearScreen(RGB(0, 0, 0))
If ExamineMouse()
If MouseButton(#PB_MouseButton_Left)
Debug "Left button " + Str(SpriteCount)
ZoomSprite(SpriteCount, 200, 200)
SpriteX = MouseX()-SpriteWidth(SpriteCount)/2
SpriteY = MouseY()-SpriteHeight(SpriteCount)/2
Debug SpriteX
Debug SpriteY
DisplaySprite(SpriteCount, SpriteX, SpriteY)
SpriteCount = SpriteCount+1
If SpriteCount > 3
SpriteCount = 1
EndIf
Debug "Next " + Str(SpriteCount)
EndIf
If MouseButton(#PB_MouseButton_Right)
Debug "Right button"
EndIf
If MouseButton(#PB_MouseButton_Middle)
Debug "Middle button"
EndIf
WheelDelta = MouseWheel()
If WheelDelta
Debug "Mouse wheel: " + WheelDelta
EndIf
Else
Debug "Cannot"
EndIf
FlipBuffers()
;// continue the rendering
EndProcedure
; Register the loading event before calling any resource load command
BindEvent(#PB_Event_RenderFrame, @RenderFrame())
LoadSprite(1, "Data/1.jpg")
LoadSprite(2, "Data/2.jpg")
LoadSprite(3, "Data/3.jpg")
FlipBuffers()