ProductPromotion
Logo

Kotlin

made by https://0x3d.site

GitHub - Ayfri/PIXI-Kotlin: Kotlin/JS bindings for PIXI.js library.
Kotlin/JS bindings for PIXI.js library. Contribute to Ayfri/PIXI-Kotlin development by creating an account on GitHub.
Visit Site

GitHub - Ayfri/PIXI-Kotlin: Kotlin/JS bindings for PIXI.js library.

GitHub - Ayfri/PIXI-Kotlin: Kotlin/JS bindings for PIXI.js library.

GitHub Workflow Status Sonatype Nexus (Releases) PIXI.js Version

PIXI-Kotlin

This is a simple example of what a PIXI.js transcription in Kotlin could look like.

For now, there are all the classes, interfaces, enums, functions, type aliases, and objects. The private members are not present.

The types are from PIXI 6.5.2.

Usage

To use it in a project, just add this to your dependencies:

repositories {
	...
	mavenLocal()
}

dependencies {
	implementation("io.github.ayfri:PIXI-Kotlin:VERSION")
}

If you want to add optional PIXI modules, you have to implement them in your project.

const val PIXI_KOTLIN_VERSION = "VERSION"

dependencies {
	implementation("io.github.ayfri:PIXI-Kotlin:PIXI_KOTLIN_VERSION")
	implementation("io.github.ayfri:PIXI-Kotlin-unsafe-eval:PIXI_KOTLIN_VERSION")
}

Example

Simple application with a sprite, size change when clicking.

fun main() {
	val app = application {
		backgroundColor = Color(120, 200, 230)
		resizeTo = window
	}
	app.addToBody()
	
	val bunny = sprite("bunny.png") {
		setPositionFromWindow(0.5, 0.5)
		anchor.set(0.5)
		interactive = true
		addToApplication(app)
	}
	
	bunny.on(DisplayObjectEvents.mousedown) {
		bunny.scale.set(1.1)
	}
	
	bunny.on(DisplayObjectEvents.mouseup) {
		bunny.scale.set(1.0)
	}
}

Application with keymap and test if sprite sticks out of area.

fun main() {
	val app = application {
		resizeTo = window
	}
	app.addToBody()
	
	val speed = 10.0
	val sprite = sprite(generateBlankTexture(app) {
		width = 300.0
		height = 300.0
		color = Color(255, 0, 0)
	}) {
		addToApplication(app)
		anchor.set(0.5)
		setPositionFromApplication(app, 0.5, 0.5)
		window["sprite"] = this
	}
	
	val area = Rectangle(0.0, 0.0, app.screen.width, app.screen.height)
	
	app.renderer.on(AbstractRendererEvents.resize) {
		area.setSize(app.screen.width, app.screen.height)
	}
	
	
	val english = "en" in window.navigator.languages.elementAtOrElse(0) { window.navigator.language }
	KeyMap(
		mapOf(
			"forward" to setOf(if (english) "W" else "Z", "ArrowUp"),
			"backward" to setOf("S", "ArrowDown"),
			"left" to setOf(if (english) "A" else "Q", "ArrowLeft"),
			"right" to setOf("D", "ArrowRight"),
			"power" to setOf(" ")
		),
		ignoreCase = true
	).apply {
		onKeep("forward") {
			if ((sprite.hitBox.top + speed * 2) > area.top) sprite.y -= speed
		}
		onKeep("backward") {
			if ((sprite.hitBox.bottom - speed * 2) < area.bottom) sprite.y += speed
		}
		onKeep("left") {
			if ((sprite.hitBox.left + speed * 2) > area.left) sprite.x -= speed
		}
		onKeep("right") {
			if ((sprite.hitBox.right - speed * 2) < area.right) sprite.x += speed
		}
		
		onPress("power") {
			sprite.alpha = if (sprite.alpha == 0.1) 1.0 else 0.1
		}
	}
}

More Resources
to explore the angular.

mail [email protected] to add your project or resources here 🔥.

Related Articles
to learn about angular.

FAQ's
to learn more about Angular JS.

mail [email protected] to add more queries here 🔍.

More Sites
to check out once you're finished browsing here.

0x3d
https://www.0x3d.site/
0x3d is designed for aggregating information.
NodeJS
https://nodejs.0x3d.site/
NodeJS Online Directory
Cross Platform
https://cross-platform.0x3d.site/
Cross Platform Online Directory
Open Source
https://open-source.0x3d.site/
Open Source Online Directory
Analytics
https://analytics.0x3d.site/
Analytics Online Directory
JavaScript
https://javascript.0x3d.site/
JavaScript Online Directory
GoLang
https://golang.0x3d.site/
GoLang Online Directory
Python
https://python.0x3d.site/
Python Online Directory
Swift
https://swift.0x3d.site/
Swift Online Directory
Rust
https://rust.0x3d.site/
Rust Online Directory
Scala
https://scala.0x3d.site/
Scala Online Directory
Ruby
https://ruby.0x3d.site/
Ruby Online Directory
Clojure
https://clojure.0x3d.site/
Clojure Online Directory
Elixir
https://elixir.0x3d.site/
Elixir Online Directory
Elm
https://elm.0x3d.site/
Elm Online Directory
Lua
https://lua.0x3d.site/
Lua Online Directory
C Programming
https://c-programming.0x3d.site/
C Programming Online Directory
C++ Programming
https://cpp-programming.0x3d.site/
C++ Programming Online Directory
R Programming
https://r-programming.0x3d.site/
R Programming Online Directory
Perl
https://perl.0x3d.site/
Perl Online Directory
Java
https://java.0x3d.site/
Java Online Directory
Kotlin
https://kotlin.0x3d.site/
Kotlin Online Directory
PHP
https://php.0x3d.site/
PHP Online Directory
React JS
https://react.0x3d.site/
React JS Online Directory
Angular
https://angular.0x3d.site/
Angular JS Online Directory