Skip to content

Android and libGDX

The Java runtime is a pure Java port (Java 11+) with a libGDX renderer and sound, and a Kotlin OpenBoneView for Android 7+ with sound through SoundPool and MediaPlayer. Scripts run in QuickJS (openbone-scripting).

From Maven Central:

dependencies {
implementation("io.openbone:openbone-runtime:0.3.0")
implementation("io.openbone:openbone-scripting:0.3.0") // document scripts
implementation("io.openbone:openbone-android:0.3.0") // OpenBoneView
// or: implementation("io.openbone:openbone-gdx:0.3.0") // libGDX renderer and sound
}

Put the exported .obone or .obonb file and its images in your app’s assets (assets/knight/).

The Export dialog with Binary selected for the Knight
val view = OpenBoneView(context)
view.load(assets.open("knight/knight.obone").readBytes(), ImageSource.assets(assets, "knight"),
SoundSource.assets(assets, "knight"))
view.useStateMachine("knight") // or view.play("walk")
view.onEvent { e -> if (e.name == "footstep") playStep() }
view.onStateChange { layer, from, to -> Log.d("anim", "$layer: $from → $to") }
view["walk"] = true // inputs: Boolean, Number or String
view.fire("attack")
view.fit = OpenBoneView.Fit.CONTAIN

Touch and hover reach the state machine’s pointer listeners. release() stops sounds and scripts.

Reference: Java, libGDX and Android runtime

OpenBone is MIT licensed and made by UXCentury. The example art, voices and sounds are credited in the repository.