Search code examples
javaandroidrotationimageviewontouch

Java/Android: Continuously rotate ImageView image on tap of left/right side of screen


I'm currently making a Java Android game and I want to rotate a car image left/right as long as the left/right half of the screen is pressed (respectively). I couldn't seem to find any help elsewhere for this, and I have no code to show, I don't know how to do it :/. Any help is appreciated!

(Oh, and also, it seems that some code doesn't show the car actually rotating - I'd like to be able to see the image rotate when I tap the screen.) Thanks!

Any help is appreciated!


Solution

  • I can't comment as I don't have the rep for it yet...boohoo!

    But I think I have something that might help you...

    http://www.tutorialspoint.com/android/android_animations.htm

    The tutorial shows how to animate a view. Maybe if your Car image is a ImageView you can rotate it (if you mean move it?) by coding a game like pattern behind your buttons.

    Is car moving? No. If left or right button pressed? Left. Reprint Image to the left per center pixel till left button is unclicked.

    With a method then that recreates it every second in the direction of the button you have pressed?