Last active
August 29, 2015 14:06
-
-
Save JavadocMD/37030357f7f6bd38d173 to your computer and use it in GitHub Desktop.
Rendering spinning number wheels
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Setup the data for our elements... | |
lazy val stop: Stream[Float] = 3f #:: stop.map(_ + .5f) | |
lazy val dt: Stream[Float] = 0f #:: .10f #:: .05f #:: -.05f #:: dt | |
lazy val dx: Stream[Int] = Stream.from(0, 15) | |
// I can have as many elements as I want by adjusting this number. | |
val values = (stop, dt, dx).zipped.take(10) | |
override def render() = { | |
time += Gdx.graphics.getDeltaTime() | |
Gdx.gl.glClearColor(clear.r, clear.g, clear.b, clear.a); | |
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); | |
batch.begin(); | |
// And render all of them! | |
values map { case (stop, offset, dx) => | |
val tex = if (time > stop) w7 else anim.getKeyFrame(time + offset) | |
batch.draw(tex, 200 + dx, 200) | |
} | |
batch.end(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment