Skip to content

Instantly share code, notes, and snippets.

@noisesmith
Last active December 20, 2015 19:08
Show Gist options
  • Save noisesmith/6180538 to your computer and use it in GitHub Desktop.
Save noisesmith/6180538 to your computer and use it in GitHub Desktop.
(ns clojure.gdx.myscreen
(:import (com.badlogic.gdx Gdx Screen)
(com.badlogic.gdx.scenes.scene2d Stage)
(com.badlogic.gdx.scenes.scene2d.ui Label Label$LabelStyle)
(com.badlogic.gdx.graphics Color)
(com.badlogic.gdx.graphics.g2d BitmapFont)
(com.badlogic.gdx.graphics.g2d SpriteBatch)))
(declare ^Stage stage)
(defn allocate []
(let [sprites (SpriteBatch.) font (BitmapFont.)])
(fn [] (.dispose sprite) (.dispose font)))
(defn screen []
(let [stage (Stage.)
cleanup-memory (allocate)]
(proxy [Screen] []
(show []
(let [style (Label$LabelStyle. font (Color. 1.0 1.0 1.0 1.0))
label (Label. "Hello Clojure!" style)]
(.addActor stage label)))
(render [delta]
(doto stage
(.act delta)
(.draw)))
(dispose
(cleanup-memory))
(hide [])
(pause [])
(resize [w h])
(resume []))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment