With a larger image than the screen, and scrolling, do you know how to keep the image centered when I zoom ?
Is my question understandable ?
Code: Select all
If InitSprite() = 0 Or InitKeyboard() = 0 Or InitMouse() = 0 Or OpenWindow(0, 0, 0,800, 600, "zoom", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)=0 Or OpenWindowedScreen(WindowID(0), 0, 0, 800, 600, 0, 0, 0)=0:MessageRequester("Error", "Error", 0):End:EndIf
Xresolution=800:Yresolution=600
;back sprite
CreateSprite(0,4000,2000):StartDrawing(SpriteOutput(0)):For j=0 To 20:For i=0 To 40:Circle(i*100,j*100,50,Random($FFFFFF)):Next i:Next j:StopDrawing()
;mouse sprite
CreateSprite(1,32,32):StartDrawing(SpriteOutput(1)):Box(0,0,32,32,#Red):StopDrawing()
;coordonnées world
X=0:Y=0:MouseLocate(120,120)
Repeat
FlipBuffers()
ClearScreen(#Blue)
ExamineKeyboard()
ExamineMouse()
If WindowEvent()=#PB_Event_CloseWindow Or KeyboardReleased(#PB_Key_Escape):End:EndIf
Xmouse=MouseX():Ymouse=MouseY():tick.i=MouseWheel()
;scroll if mouse on the edge of the screen
If Xmouse<10:X+10:EndIf
If Xmouse>Xresolution-10:X-10:EndIf
If Ymouse<10:Y+10:EndIf
If Ymouse>Yresolution-10:Y-10:EndIf
;zoom
If tick
ZoomWorld+100*tick
ZoomSprite(0,4000+ZoomWorld,2000+ZoomWorld>>1)
EndIf
;back
DisplaySprite(0,X,Y)
;mouse
DisplaySprite(1,Xmouse,Ymouse)
ForEver