简体   繁体   English

Java / Android:连续旋转屏幕左/右侧的ImageView图像

[英]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). 我目前正在制作Java Android游戏,只要按下(分别)屏幕的左/右半部分,我想左/右旋转汽车图像。 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! 任何帮助表示赞赏!

I can't comment as I don't have the rep for it yet...boohoo! 我无法评论,因为我还没有它的代表...... boohoo!

But I think I have something that might help you... 但我想我有一些可能对你有帮助的东西......

http://www.tutorialspoint.com/android/android_animations.htm 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. 也许如果您的Car图像是ImageView,您可以旋转它(如果您的意思是移动它?),通过在按钮后面编写类似游戏的模式。

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? 使用一种方法,然后在按下按钮的方向上每秒重新创建一次?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM