Hi, I started to use the LibGDX library a few days ago and I didn´t find in the examples how to zoom in and out the camera and how to scroll(up,down,left to right), Im working in the ShapeRender example, this one create basic objects(circles, squares) and you can rotate them, I remove the rotate function and tried to add some type of scroll function but it doesn´t work all the time, when the camera is really far away from the (0,0,0) (big objects) the scroll is really slow and when the camera is near the (0,0,0) the scroll is very fast. Im using this code:
And for the multitouch function (zoom in and out) I could not come up with something.
My question is how to enable some type of function in which I can zoom in and out and scroll up-down,left-right. Just like any photo in a touchscreen display.
Thanks
B4X:
Sub IP_TouchDown(ScreenX As Int, ScreenY As Int, Pointer As Int) As Boolean
If Pointer <> 0 Then Return False
LastX = ScreenX
LastY = ScreenY
Return True
End Sub
Sub IP_TouchDragged(ScreenX As Int, ScreenY As Int, Pointer As Int) As Boolean
Point.Set(Camera.Position.X, Camera.Position.Y, Camera.Position.Z)
Camera.Position.Set(Point.X, Point.y, Point.Z)
Dim speedx, speedy As Double
speedx = Abs(ScreenX-LastX)/100
speedy = Abs(ScreenY-LastY)/100
If Pointer <> 0 Then Return False
If ScreenX > LastX Then
Camera.Translate(-speedx, 0, 0)
Else
Camera.Translate(speedx, 0, 0)
End If
If ScreenY > LastY Then
Camera.Translate(0,speedy,0)
Else
Camera.Translate(0,-speedy,0)
End If
Camera.Update
LastX = ScreenX
LastY = ScreenY
Return True
End Sub
And for the multitouch function (zoom in and out) I could not come up with something.
My question is how to enable some type of function in which I can zoom in and out and scroll up-down,left-right. Just like any photo in a touchscreen display.
Thanks