Results 1 to 1 of 1
- 09-10-2013, 08:27 PM #1
Member
- Join Date
- Sep 2013
- Posts
- 2
- Rep Power
- 0
I added a sprite sheet but i have one question
First of all i don't know if im in the right area of the forum.
i added this code
Java Code:public class Animator implements ApplicationListener { private static final int FRAME_COLS = 6; // #1 private static final int FRAME_ROWS = 5; // #2 Animation walkAnimation; // #3 Texture walkSheet; // #4 TextureRegion[] walkFrames; // #5 SpriteBatch spriteBatch; // #6 TextureRegion currentFrame; // #7 float stateTime; // #8 @Override public void create() { walkSheet = new Texture(Gdx.files.internal("animation_sheet.png")); // #9 TextureRegion[][] tmp = TextureRegion.split(walkSheet, walkSheet.getWidth() / FRAME_COLS, walkSheet.getHeight() / FRAME_ROWS); // #10 walkFrames = new TextureRegion[FRAME_COLS * FRAME_ROWS]; int index = 0; for (int i = 0; i < FRAME_ROWS; i++) { for (int j = 0; j < FRAME_COLS; j++) { walkFrames[index++] = tmp[i][j]; } } walkAnimation = new Animation(0.025f, walkFrames); // #11 spriteBatch = new SpriteBatch(); // #12 stateTime = 0f; // #13 } @Override public void render() { Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT); // #14 stateTime += Gdx.graphics.getDeltaTime(); // #15 currentFrame = walkAnimation.getKeyFrame(stateTime, true); // #16 spriteBatch.begin(); spriteBatch.draw(currentFrame, 50, 50); // #17 spriteBatch.end(); } }
i would like to know how would i start the sprite sheet in a random row and col for example row 7 col 3
Any help would be great thank you for reading
here is a link of the original code
https://code.google.com/p/libgdx/wiki/SpriteAnimationLast edited by JosAH; 09-10-2013 at 08:29 PM. Reason: added [code] ... [/code] tags
Similar Threads
-
Flickering on a 2D Sprite
By driiper in forum Java 2DReplies: 5Last Post: 05-06-2012, 05:30 PM -
import sprite
By Bimz in forum New To JavaReplies: 0Last Post: 08-28-2011, 12:15 PM -
Sprite-sheet vs individual images
By David M. in forum Java GamingReplies: 9Last Post: 08-13-2011, 08:02 PM -
Confisuion about sprite.getX() and sprite.getY()
By Basit781 in forum Java GamingReplies: 0Last Post: 01-10-2011, 06:16 AM -
JExcel: Copy a cell content from one sheet to another sheet in the same workbook.
By ukbasak in forum Advanced JavaReplies: 0Last Post: 08-02-2007, 12:31 PM
Bookmarks