简体   繁体   中英

How can I compile Kotlin code to JavaScript for use in my LibGDX web application?

I am trying to run Kotlin code in my LibGDX project, and it works successfully in the desktop application, however as of now, kotlin is not supported in the Google Web Toolkit, which only compiles java code into JS.

The libGDX wiki mentions that it may be possible to compile kotlin code into JS using the built in Kotlin functionality, so, how would I go about compiling Kotlin code into JS for use with my GWT webapp? Is that even possible with libGDX's current structure, or should I just continue trying to implement TeaVM into my project, which supports JVM bytecode?

If TeaVM is a better solution or any knowledge is had on that, I asked another question just recently on how to implement TeaVM to LibGDX: How can I add TeaVM to my existing libGDX project?

I've had a lot of difficulty trying to figure this out for a while now, and any help would be greatly appreciated as I find it quite essential to my project!

No, I don't think so It's possible to convert kotlin + LibGDX project to JavaScript.

Converting Java code to Kotlin is not a 100% automated process so Java code can't compile to JavaScript using Kotlin2JS. 1

kotlin2js is source-to-source transpiler and it knows nothing about Java and Java libraries. LibGDX is written in Java, so you can't write your libGDX game on Kotlin and transpile it to JavaScript.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM