Jaime Guerrero
09/27/2020, 9:02 PMval size = 800.0
val cam = Camera(0.0, 0.0, size, size)
val container = cameraContainer(size, size) { ... }
container.camera = cam
First, I have a soccer ball image in the middle of the screen and I’m using its position to move the cam.
container.addFixedUpdater(ConfigModule.FPS.timesPerSecond) {
...
launchImmediately {
if (match.state == State.TakingPhoto) cam.zoom += 0.02 // This line for the second question
cam.moveTo(ballRenderer.image.x - ConfigModule.halfScreenSizeWidth / cam.zoom,
ballRenderer.image.y - ConfigModule.halfScreenSizeHeight / cam.zoom, 1.nanoseconds, Easing.SMOOTH)
}
}
This works but I would like to add some delay in the camera movement. For this, using 1.seconds
instead of 1.nanoseconds
I get the correct delay. The problem is that in this case, I can see the ball a bit laggy, almost two balls at the same time in the screen, maybe due to the animation. Is there another way to do this?
My second question is the zoom. I would like to change the zoom in any moment but I don’t know how to do it correctly. When the match is in the TakingPhoto
state (about 50 iterations) I take advantage of this to zoom in while the ball is stopped.
if (match.state == State.TakingPhoto) cam.zoom += 0.02
I think this way is a mini hack. This works perfectly but I would like to choose in any moment of the match another zoom, but using an animation. I mean, if my current zoom is 1.5 and the ball position is off the soccer pitch for example, I need to change it from 1.5 to 1.0. Which is the correct way to change the zoom using an animation while is positioning in a point?
Thaaaanks!Deactivated User
09/28/2020, 6:08 PMJaime Guerrero
09/28/2020, 6:23 PMballRenderer.render(match.getBallPosition())
and after moving the camera. I have tested moving the camera first but the result is the same. If I use 0.1.seconds the result is worse. 1.nanoseconds is because I cannot set 0 to remove the delay.
I saw this camera example here:
https://github.com/korlibs/korge-samples/tree/master/camera
I think this example is using korge 2.0Deactivated User
10/01/2020, 7:41 AMfollow
method to follow the ball with anchor to the centerJaime Guerrero
10/01/2020, 12:24 PM