I haven’t been able to find much code/tutorials on Moving an object with Threads in Java for Android. I would like some help or code on moving the X and Y position with Threads in Java for Android.
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.
The main hurdle you are facing is that you are thinking of the location of drawing the bitmap being somehow tied to the bitmap itself. You need to track them separately. int draw_x and int draw_y and update those values using your thread or a timer or whatever means you want. Then, in the onDraw method of your view, you want to canvas.translate to the position draw_x,draw_y and then draw your bitmap.
You don’t want to “move the bitmap”, you want to alter the translation of the canvas when the bitmap is drawn.