This is the error:
Execution error (UnsupportedOperationException) at bucket_drops_screen_extension.main_menu.proxy$java.lang.Object$Screen$e6e56cf1/show (REPL:-1).
show
This is my code:
(defn screen
[]
(proxy [java.lang.Object Screen] []
(render [delta]
(.clear ScreenUtils Color/BLACK)
(.apply (deref globals/viewport))
(let [matrix (.. @globals/viewport getCamera combined)]
(.setProjectionMatrix @globals/sprite-batch matrix))
(.begin @globals/sprite-batch)
(.draw @globals/font @globals/sprite-batch "test" 1 1)
(.end @globals/sprite-batch))
(resize [x y]
(.update @globals/viewport x y true))))
Full code here. I'm trying to follow this tutorial.
What is wrong with my code?
And maybe more in general: How to get to what's wrong from this error message?
Screen
is an interface which a bunch of methods on it, one of them show
. See the javadoc.
When a method is called on a class that does not implement the called interface method you get a UnsupportedOperationException
. So you either need to add that to your proxy
or instead use the ScreenAdapter which to implement these and letting you override only whats needed.
FWIW interfaces can be implemented directly on CLJ types such as deftype
or defrecord
. Or alternatively using reify
. proxy
is only generally needed for classes that you are supposed to inherit, which CLJ can't really do otherwise.