Container Pivot
package basics
import kotlin.browser.document
import kotlin.js.json
fun main(args: Array<String>) {
val app = PIXI.Application(800, 600, json(
"backgroundColor" to 0x1099bb
))
document.body!!.appendChild(app.view)
val container = PIXI.Container()
app.stage.addChild(container)
val texture = PIXI.Texture.fromImage("../assets/basics/bunny.png")
for (i in 0 until 25) {
val bunny = PIXI.Sprite(texture)
bunny.anchor.set(0.5)
bunny.x = (i % 5) * 40
bunny.y = kotlin.math.floor(i.toDouble() / 5) * 40
container.addChild(bunny)
}
container.x = app.screen.width.toDouble() / 2
container.y = app.screen.height.toDouble() / 2
container.pivot.x = container.width.toDouble() / 2
container.pivot.y = container.height.toDouble() / 2
app.ticker.add({ delta ->
container.rotation = container.rotation.toDouble() - 0.01 * delta.toDouble()
})
}