korge: add rotation
parent
8d4ba39793
commit
cb8867af2e
|
|
@ -34,6 +34,7 @@ class ViewDocument(private val document: Document) : Scene() {
|
|||
var scaleFactor = 0.5
|
||||
var offset = Point(0.0,0.0)
|
||||
val moveFactor = 50.0
|
||||
var rotationFactor = 0.0
|
||||
scale(scaleFactor)
|
||||
|
||||
suspend fun zoom(amount: Double) {
|
||||
|
|
@ -60,6 +61,15 @@ class ViewDocument(private val document: Document) : Scene() {
|
|||
easing = Easing.EASE_IN_OUT)
|
||||
}
|
||||
|
||||
suspend fun rotateBy(amount: Double){
|
||||
rotationFactor += amount
|
||||
tween(
|
||||
this@sceneMain::rotation[rotationFactor.degrees],
|
||||
time = 0.1.seconds,
|
||||
easing = Easing.EASE_IN_OUT
|
||||
)
|
||||
}
|
||||
|
||||
keys {
|
||||
down { key ->
|
||||
when (key.key) {
|
||||
|
|
@ -69,6 +79,8 @@ class ViewDocument(private val document: Document) : Scene() {
|
|||
Key.DOWN -> moveY(-moveFactor)
|
||||
Key.RIGHT -> moveX(moveFactor)
|
||||
Key.LEFT -> moveX(-moveFactor)
|
||||
Key.E -> rotateBy(10.0)
|
||||
Key.R -> rotateBy(-10.0)
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue