clojure

java interop: No matching method found


I'm trying to call a method of a java library:

(.draw (:sprite-batch @resources) (:bucket @resources) 0.0 0.0 1.0 1.0)

And get this error:

Execution error (IllegalArgumentException) at bucket-drops.core/draw (core.clj:29).
No matching method draw found taking 5 args for class com.badlogic.gdx.graphics.g2d.SpriteBatch

There clearly is a method that takes 5 arguments: javadoc for SpriteBatch. Actually, there are two: one taking a TextureRegion as its first argument, the other a Texture. Could this be the problem, that clojure can't distinguish between the two? If so, what can I do about it? If not, what else might cause the problem?

Full code here.


Solution

  • Eugene Pakhomovs answer brought me on the right track. This works too:

    (.draw (:sprite-batch @resources) (:bucket @resources) (float 0) (float 0) (float 1) (float 1))
    

    I'm pretty sure that java would accept doubles (or even ints), but it seems for clojure I need to match the signature exactly.