electronstudio / jaylib

Java JNI bindings for Raylib
Other
124 stars 23 forks source link

bug with Rectangle() #19

Closed Augusto-Fadanelli closed 3 years ago

Augusto-Fadanelli commented 3 years ago

when i use and compile: this.teste = new Rectangle(0.0f, 0.0f, 64.0f, 64.0f);

I receive this:

BattleTank.java:54: error: no suitable constructor found for Rectangle(float,float,float,float) this.teste = new Rectangle(0.0f, 0.0f, 64.0f, 64.0f); ^ constructor Rectangle.Rectangle() is not applicable (actual and formal argument lists differ in length) constructor Rectangle.Rectangle(long) is not applicable (actual and formal argument lists differ in length) constructor Rectangle.Rectangle(Pointer) is not applicable (actual and formal argument lists differ in length) 1 error

i didn't build jaylib and i running it in windows 7 x64

electronstudio commented 3 years ago

The helper class for Rectangle was added here so I think it's not in the released jar. https://github.com/electronstudio/jaylib/commit/c2546ad991fe6e3e072600d9a3d43108d27d46c5

You could copy and paste the code from there into your project, or you could wait until I release a new jar.

electronstudio commented 3 years ago

actually if you're copy and pasting, use this version https://github.com/electronstudio/jaylib/blob/master/src/com/raylib/Jaylib.java

Augusto-Fadanelli commented 3 years ago

the file "com/raylib/Raylib.java" does not exist, do I need to create it to build? How I do it? thanks for your patience

electronstudio commented 3 years ago

I'm currently thinking the best way is just to do:

    this.teste = new Rectangle().x(0.0f).y(0.0f).width(64.0f).height(64.0f);

To discuss if it would be better to use helper classes go to #1

electronstudio commented 3 years ago

I'm thinking the helpers are not actually a good idea, because they make it easy to think you're dealing with Java objects, when actually these are chunks of memory allocated on the native heap. The GC behaviour is different and the JVM won't be able to do boxing, escape analyse, etc, optimizations on them. The unusual syntax helps to remind me of that.

But anyway the helpers are still there.