More specifically, I have rotation working in a way I don't like as follows:
//Draw the triangle using this draw method //batch.draw(texture, x, y, originX, originY, width, height, scaleX, scaleY, rotation, srcX, srcY, srcWidth, srcHeight, flipX, flipY) batch.draw(triangle, 240 - triangle.getWidth() / 2, (float) (400 - triangle.getWidth() * .289), triangle.getWidth() / 2, (float) ((double) triangle.getWidth() * 0.288), triangle.getWidth(), triangle.getHeight(), 1, 1, rotate, 0, 0, triangle.getWidth(), triangle.getHeight(), false, false); batch.end(); //Touch input if(Gdx.input.isTouched()){ Vector3 touchpos = new Vector3(); touchpos.set(Gdx.input.getX(), Gdx.input.getY(), 0); camera.unproject(touchpos); rotate = touchpos.x; } This rotates the triangle around the center of the triangle that is at the center of the screen (the 0.289 corresponds to the height of the middle of an equilateral triangle according to its side length).
The rotation will be equal to the touch position on the screen which works great when the finger is dragged. However, what this code does is moves the rotation to the specific location whenever I touch the window with the mouse. What I would like it to do is to rotate the triangle when the mouse is dragged, but only based on its previous rotation, not its absolute rotation. For example, if I click and drag the mouse from the left side of the window to the right, the triangle will rotate accordingly. When I lift the mouse then click and drag it the same way a second time, I don't want it to reset it's position to my 2nd click, I want it to move the amount I dragged my mouse from it's previous rotation.
Can anyone help with this? I've been trying to wrap my head around it for hours. Let me know if you need any clarifications.