开发者

how to stop spinning bottle at random positions/angles in android?

I am working on an app in which i have to spin a object like in "Spin The Bottle" app.

Rotation has been started using R开发者_如何转开发otateAnimation but problem is that is stops every time at same position. I want to stop it randomly. Please help me.

Thanks in Advance


How are you calling the function?

The documentation here: http://developer.android.com/reference/android/view/animation/RotateAnimation.html

shows a few different constructors... one taking a start angle and a stop angle. All you need to do is use a random number function to generate the stop angle and pass that in:

    RotateAnimation(0, randomNumber);

Of course if you want it to start from the previous position you just need to keep that number in a separate variable and pass it in as the first parameter.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜