voddan
05/08/2021, 3:31 PMMax
05/10/2021, 11:29 AMval cameraBounds = ClipContainer(1000.0, 1000.0)
val camera = Camera()
cameraBounds.addChild(camera)
camera.addChild(gameContainer)
stage.addChild(cameraBounds)
and gameContainer
is a Container holding all world game objectsvoddan
05/14/2021, 6:38 PMMax
05/17/2021, 6:14 AMfun Camera.setTo(x:Double, y:Double, zoom: Double){
val stage = this.stage!!
this.setTo(
Rectangle(
stage.x + x * stage.scaleX - stage.scaledWidth / 2 * zoom,
stage.y + y * stage.scaleY - stage.scaledHeight / 2 * zoom,
stage.scaledWidth * zoom,
stage.scaledWidth * zoom,
)
)
}
Max
05/17/2021, 6:16 AMvar zoom = 1.0
...
stage.addUpdater {
...
camera.setTo(localPlayer.container.x, localPlayer.container.y, zoom)
}
to center the camera on the player, Seems to work well 👍voddan
05/17/2021, 12:19 PM