LibKTX on the web #443
Replies: 7 comments 72 replies
-
Very nice! I can confirm it works on both Firefox and Chrome on Linux Pop!_OS, sounds and all. I'm sure even a very rough guide would be useful for many KTX developers. :) Thanks for sharing your thoughts. |
Beta Was this translation helpful? Give feedback.
-
I went ahead and added TeaVM support to @Quillraven, would you have some time to test the new web backend with some of your games? |
Beta Was this translation helpful? Give feedback.
-
Cool that sounds interesting. I will give it a try on the weekend 🙂 Funny enough I just recently saw a dev blog of a YouTuber who made a little puzzle game with LibKTX and Kotlin and at some point he found out that with that setup he can't run it in the web. So he converted everything to Java to use GWT. I guess once I see it working myself I will let him know in the YT comments about this approach. Thanks for sharing! edit: some short hints how to use that stuff would be ideal because from a first glimpse I don't get it what you are supposed to do. Do you run the Gdx-Html5-Generator on the normal generated LibGDX jar? If so, how do you even run this generator? Or do you create a separate application launcher for web? I saw there should be a WebApplication and TeaApplicationConfiguration class but following the instructors of the ReadMe, I don't get it to work. // added this to the repositories in root build.gradle
maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' }
maven { url "https://oss.sonatype.org/content/repositories/releases/" }
// added this to gradle.properties
gdxWebToolsVersion = 1.0.0-SNAPSHOT
// created a new build.gradle inside a 'web' folder for the web launcher
apply plugin: 'application'
mainClassName = 'com.github.quillraven.mysticwoods.web.WebLauncher'
eclipse.project.name = appName + '-web'
sourceCompatibility = 1.8
dependencies {
implementation "com.github.xpenatan.gdx-web-tools:backend-web:$gdxWebToolsVersion"
implementation "com.github.xpenatan.gdx-web-tools:backend-teavm:$gdxWebToolsVersion"
implementation "com.github.xpenatan.gdx-web-tools:backend-teavm-native:$gdxWebToolsVersion"
implementation "com.github.xpenatan.gdx-web-tools:gdx-box2d-teavm:$gdxWebToolsVersion"
implementation project(':core')
}
// finally created a new WebLauncher class
fun main() {
WebApplication(MysticWoods(), TeaApplicationConfiguration("MysticWoods"))
} But when I run it, I get: Exception in thread "main" java.lang.UnsatisfiedLinkError: org.teavm.jso.browser.Window.current()Lorg/teavm/jso/browser/Window; |
Beta Was this translation helpful? Give feedback.
-
Hi, don't use box2d-teavm for now, not all methods/classes are ported yet. box2d-teavm use emscripten and webidl and only classes/methods in this file https://github.com/xpenatan/gdx-teavm/blob/master/extensions/gdx-box2d/gdx-box2d-build/jni/box2D.idl will work. You can use the java-gwt version. For other errors, TeaVM have very small support for reflection. It also makes JS bigger. I recommend to stick to just the reflection used in this Test class https://github.com/xpenatan/gdx-teavm/blob/master/examples/core/core/src/main/java/com/github/xpenatan/gdx/examples/tests/ReflectionTest.java Errors in Class: Class.isAnonymousClas Looks like it does not exist in teavm. |
Beta Was this translation helpful? Give feedback.
-
KTX sample projects are now generated with
All modules using coroutines (ending with |
Beta Was this translation helpful? Give feedback.
-
Assets like sound/music should work fine if they’re loaded with your bog standard long DX asset manager. They worked for me with my crappy pong test |
Beta Was this translation helpful? Give feedback.
-
Hello everyone... I am trying to get this to work with my game that I submitted for the latest libgdx-jam. To start off, I use Ashley - would that be a problem or is it fine? Everything works fine until my game starts trying to create components, throwing the no-arg-constructor-exception below: Also this exception: Is this perhaps related to the fact that Reflection doesn't work well? I can probably work around that if that's the case, I'll just add a builder or factory or my own pooling as needed, I use ashley with a pooled engine. I gotta say, this is a game-changer of epic proportions and anything I can do to get it off the ground I will do! |
Beta Was this translation helpful? Give feedback.
-
I adore Kotlin and LibKTX! But a web export is critical, and the lack of one is what keeps me from using LibKTX for a while.
However! I recently discovered Xpenatan's repository, which allows exporting LibKTX and overall LibGDX to the web via TeaVM, and it works flawlessly, even on itch.io!
While I wish it had more detailed instructions on how to use it, as a newbie like me got quite confused with which ApplicationClass I was supposed to provide and a minor hiccup on the itch.io side causing the game to crash on the initial upload, I believe this is God's work right here lol.
I thought I'd share my experience with it because many people, including myself, want to find a way to get their LibKTX games out there, especially those interested in gamejams. While my game isn't serious and is very simple, you can try it out here.
I will try to get a rough guide on using it up at some point too!
Beta Was this translation helpful? Give feedback.
All reactions