Marco Martinelli
Reputation
421
Top tag
Next privilege 500 Rep.
Access review queues
 Nov 2 comment Passing elapsed time to the update function from the game loop @Marton thank you, I didn't know that. I've deleted my comment. Oct 15 comment Sprite Animation in Android with OpenGL ES You can find the answer here: gamedev.stackexchange.com/questions/37510/… Oct 3 comment Rotate triangle so that its tip points in the direction of the point on the screen that we last touched it is the same result as before or a different one? Oct 3 comment Rotate triangle so that its tip points in the direction of the point on the screen that we last touched Your problem is normal because you are still using `touchPos.x = (2*event.getX())/getWidth() -1.0f;` but as I've said before you should write `touchPos.x = (2*event.getX())/getWidth() -1.0f -mx;` and -my in touchPos.y Oct 2 comment Rotate triangle so that its tip points in the direction of the point on the screen that we last touched Can you update the SurfaceView code? Oct 2 comment Rotate triangle so that its tip points in the direction of the point on the screen that we last touched well, think about it. `event.getX()` goes from 0 to the value of `getWidth()` so `event.getX()/getWidth()` goes from 0 to 1. These is a 2* so the range is from 0 to 2 but your coordinates goes from -1 to 1 so subtract 1 and that's all. By the way, I was assuming that the center of the screen is (0,0) Oct 1 comment Rotate triangle so that its tip points in the direction of the point on the screen that we last touched No, scale as in `touchPos.x = (2*event.getX())/getWidth() -1.f;` Oct 1 comment Rotate triangle so that its tip points in the direction of the point on the screen that we last touched Yes it is the same use mx,my instead of rx,ry. I've supposed that your opengl screen coordinates goes from the top-left corner (-1,1) to the bottom-right corner (1,-1) If you are using different screen coordinates just scale event.getX() and event.getY() in according to them. Oct 1 comment Is it possible to emulate a MovieTexture with dynamically loaded images? How long is the video? Framerate? Oct 1 comment Rotate triangle so that its tip points in the direction of the point on the screen that we last touched ok, assuming that (rx,ry) is the center of rotation you need to do `touchPos.x-=rx; touchPos.y-=ry;` Sep 29 comment Sprite animation in openGL - Some frames are being skipped I don't mind, I've asked you just to know if it work or not. I'm curious ;) Sep 29 comment Sprite animation in openGL - Some frames are being skipped Did you tested my code? Sep 28 comment Rotate triangle so that its tip points in the direction of the point on the screen that we last touched The center of rotation of the new triangle is (0,0,0) or something else? Sep 26 comment Sprite animation in openGL - Some frames are being skipped Ok I'm editing the answer Sep 26 comment Sprite animation in openGL - Some frames are being skipped Ok I will try to explain it better, do you prefear to edit your Renderer class (easy) or only FragileSquare? Sep 26 comment Sprite animation in openGL - Some frames are being skipped Sorry, I was adding another comment because of the characters limit. No in the 1st idea you neet to replace System.currentTimeMillis() with (System.currentTimeMillis()-MyRenderer.flag2) Sep 26 comment Sprite animation in openGL - Some frames are being skipped delta is now the amount of milliseconds between each call to the draw method. In your `if(MyRender.flag2==1)` replace System.currentTimeMillis() with `t+=delta;` I forgot to tell you that you need to declare `int t;` near `int delta;` If you want to repeat the animation every time there is a collision you need to reset t to 0 when there is not a collision (example, add an else{ t=0; }) Sep 26 comment Sprite animation in openGL - Some frames are being skipped Ok, I have two solutions. In your renderer class set flag2=System.currentTimeMillis() instead of 1 when there is a collision, 0 otherwise. In the draw function replace if(MyRender.flag2==1) with if(MyRender.flag2>0). MyRender.flag2 is now your timestamp and you are still using one static member. Second idea, in your FragileSquare class add a member `long timestamp=System.currentTimeMillis();` and another one `int delta;` At the beginning of your draw method add `delta = System.currentTimeMillis(); timestamp=System.currentTimeMillis();` Sep 26 comment Sprite animation in openGL - Some frames are being skipped The frames that are being skipped are the firsts? Sep 26 comment Sprite animation in openGL - Some frames are being skipped Your sprite is 5x4 so `float rowFloat = 4.0f;` shoudn't be `float rowFloat = 5.0f;`? Also your textureCoord array is incorrect for that sprite, you should use 0.20f as v coordinate because it's 1.0/5;