-
Hi there, I'm new - new to Kotlin, new to LibGDX, new to LibKTX, new to Fleks. I'm working on a project that I would like to target several platforms; Linux, Android, web, and Windows. With LibKTX, I've got some sprites moving around based on mouse clicks. I set up TeaVM support, and got that building with surprising ease, but that version used the Ashley ECS implementation (closely following the Dark Matter YouTube tutorial playlist), and I ran into a runtime error when running in TeaVM, complaining about my TransformComponent not having a no-args constructor. I proceeded to rewrite the ECS using Fleks, and got as far as seeing some sprites drawing when running my desktop build, but I got a different runtime error in TeaVM that looks like it's complaining about my (new) TransformComponent, not able to build the companion object.
My questions are:
Basically just curious if I'm trying to do something that should work and is broken, or should work, but isn't yet, or will never work, and I should try a different approach, or will never work, and I should change my expectations. Thanks, |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 6 replies
-
I'm using |
Beta Was this translation helpful? Give feedback.
-
Half a year ago I had a very positive experience working with Looking at your code, the problematic line is in the companion object initialization block companion object : ComponentType<FLTransformComponent>() {
val log = logger<CWG2dGameScreenFleks>()
} Going deeper into the inline fun <reified T : Any> logger(): Logger = Logger(T::class.java.name) And since val log = Logger("CWG2dGameScreenFleks") Or try the Kotlin "reflection" option which tends to be more friendly with TeaVM val log = Logger(SimplePhysicsTest::class.simpleName) // <== A good candidate for your own logger() shortcut function! And by the way, |
Beta Was this translation helpful? Give feedback.
-
Wow thanks @metaphore for your quick response and help! Fyi registering the logger class as reflection class might help. I did that in a newer project for some other reflection classes. Here is the link to the important file: Might be worth a shot. Otherwise move your logger to the system instead of the component. I personally would not add a logger to a component. It should be a stupid data holder with ideally no logic. Logging should be part of a system. |
Beta Was this translation helpful? Give feedback.
Half a year ago I had a very positive experience working with
KTX
+Fleks
+gdx-teavm
on my jam project. So I can tell that it stacks up nicely together except for some very rare edge cases mostly related to missing bits and pieces ingdx-teavm
regards non-critical Java/libGDX API emulation for the web (like number formatting, regex, etc; but those holes could be patched since).Looking at your code, the problematic line is in the companion object initialization block
Going deeper into the
logger()
function, you can clearly see that it uses reflection: