AnimatedSprite
@file:Suppress("DEPRECATION")
package demos
import kotlin.browser.document
import kotlin.js.Math
fun main(args: Array<String>) {
val app = PIXI.Application()
document.body!!.appendChild(app.view)
app.stop()
fun onAssetsLoaded() {
val explosionTextures = ArrayList<PIXI.Texture>()
(1 until 28).mapTo(explosionTextures) { i -> PIXI.Texture.fromFrame("Explosion_Sequence_A $i.png") }
for (i in 0 until 50) {
val explosion = PIXI.extras.AnimatedSprite(explosionTextures.toTypedArray())
explosion.x = Math.random() * app.screen.width.toDouble()
explosion.y = Math.random() * app.screen.height.toDouble()
explosion.anchor.set(0.5)
explosion.rotation = Math.random() * kotlin.math.PI
explosion.scale.set(0.75 + Math.random() * 0.5)
explosion.gotoAndPlay(Math.random() * 27)
app.stage.addChild(explosion)
}
app.start()
}
PIXI.loader
.add("spritesheet", "../assets/mc.json")
.load({ _, _ -> onAssetsLoaded() })
}