How just move image in canvas? There are no x\y coordinates which I can change by += or -=.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Canvas is an immedate drawing surface. When you make a call like
drawImagethe canvas renders the bitmap to the context and then forgets that anything ever happened. It keeps track of nothing.That means you need to keep track of everything. If you want the image you move, you need to clear the canvas and redraw the image (and everything else in the scene) at a different location than before.
This comes up a lot in various ways so I made a tutorial on managing the state of drawn objects and canvas interactivity that serves as a decent introduction to this topic. The tutorial uses rectangles that you can drag around the screen, but using images is nearly identical.