324 reputation
137
bio website fantasyvengeance.com
location Italy
age 26
visits member for 1 years, 7 months
seen Dec 28 '13 at 17:26

Java and Android developer with interests in 3D stuff and game development.

Linux user since 2003, self taught in electronic, former musician.

Graduated in "Computer Science" at the University of Verona (Italy) with a thesis involving ARM boards, real time OSs and custom graphic libraries.

Three time winner at the National Turing Machine Contest of the University of Pisa (Italy) back in high school.


Sep
24
comment sprite animation in openGL
@Sid see my edited answer, I have totally forgot that you need to reset the texture matrix. That's why your background was translated. Place that code snipped at the end of your draw function and it should work.
Sep
24
revised sprite animation in openGL
added 272 characters in body
Sep
24
comment sprite animation in openGL
Ok, where is int idx = ((System.currentTimeMillis()%(200*4))/200); ?? without that it can't work.. Also, you didn't tell me, are you using the same draw function for sprite and background?
Sep
24
comment sprite animation in openGL
@Sid post your updated code, I will check that
Sep
24
comment sprite animation in openGL
@Sid Are you using the same draw function for your sprite and your background? You should split your code in two classes, one that manage the background and another one that manage your sprite but for now you can surround the glTranslatef call with an if that check if you are drawing the sprite.
Sep
24
comment sprite animation in openGL
@Sid yes, put my code in your draw function and it should work. If it doesn't post the edited code and I will check it.
Sep
23
comment sprite animation in openGL
@Sid ok, assuming that you are now able to translate the uv space and that you are using 2x2 spriteset, put in draw int idx = ((System.currentTimeMillis()%(200*4))/200); this is untested but should give you a variable idx (index) that change value every 200ms from 0 to 3 This is your "current frame" index Use that index to found your u and v frame coordinate and pass that to glTranslatef, example for 2x2 spriteset, gl.glTranslatef((idx%2)/2, (idx/2)/2, 0);
Sep
23
comment sprite animation in openGL
@Sid in your draw function after gl.glEnable(GL10.GL_TEXTURE_2D); paste those three lines gl.glMatrixMode(GL10.GL_TEXTURE); gl.glTranslatef(u, v, 0); gl.glMatrixMode(GL10.GL_MODELVIEW); You need to change the u and v values, for example if your 2nd frame start at (0.5, 0) call glTranslatef(0.5, 0, 0) If you are unsure just experiment a bit ;)
Sep
23
comment sprite animation in openGL
@Sid UV coordinates for glTexCoordPointer need to be stored in 1D array
Sep
23
comment sprite animation in openGL
@Sid Yes, it is the same thing, you just need to use the right uv mapping coordinates. Try to adapt my code snippet than if you need more help post your code
Sep
23
answered sprite animation in openGL