Created
October 12, 2014 07:36
-
-
Save loriopatrick/cba1f0e03e9b8888c234 to your computer and use it in GitHub Desktop.
TextureRegion
This file contains hidden or 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
TextureRegion[][] parts = TextureRegion.split(new Texture("path.png"), 15, 23); | |
boolean[][] used = new boolean[parts.length][parts[0].length]; | |
Random random = new Random(); | |
int ix = random.nextInt(used.length); | |
int iy = random.nextInt(used[0].length); | |
while (used[ix][iy]) { | |
// todo: pick new | |
} | |
SpriteBatch spriteBatch = new SpriteBatch(); | |
spriteBatch.begin(); | |
spriteBatch.draw(parts[ix][ix], parts[0][0].getRegionWidth() * ix, 0); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment