rotating Pimage controlled by mouse to be displayed on screen with mouse click

edited December 2017 in How To...

I have a rotating Pimage that is rotating in the center of the cursor position so it is controlled by mouseX and mouseY. What I want to accomplish is this: when I click on the screen I want the rotating image to appear on the screen "frozen" in its rotation along its own axis. With every mouse click I want a new picture to be displayed. Each image will have its own rotation and position. Could you please explain a way that I can do this or give me some suggestion that I can look up . Also, I already have a new picture appear with each new mouse click, so I don't need help with that. I just need to make sure that the image is being "stamped" on screen with its position and rotation at the time of clicking.

Answers

  • I already have a new picture appear with each new mouse click

    That is great you can do that. If you post your code, then it will be easier to show you what you want to do, instead of us writing all the code from scratch. To answer your question, you can do this either two ways:

    • You create a class that stores the x,y and current rotation angle when you clicked with the mouse. Then you create an ArrayList storing all objects created in your session. At the end of draw, you will draw the image at those locations in the array.
    • Another way, more efficient, is to stored the clicked images in a second buffer. Then you display this buffer as you background image.

    Kf

Sign In or Register to comment.