我制作的应用程序中,盘子上有一个苹果。我想把这个苹果放在盘子上然后放置后让苹果跳,直到用户无法点击它。我不知道该怎么做。
任何关于在盘子上上下移动苹果的帮助。我可以通过任何课程来完成这项任务。
答案 0 :(得分:0)
使用2D graphics或OpenGl获得此类效果,2D图形将易于实现,但如果您想要提高性能,请使用openGL。这可以与您的应用程序逻辑结合使用。
答案 1 :(得分:0)
例如: 保存在res / anim / rocket.xml的XML文件:
<?xml version="1.0" encoding="utf-8"?>
<animation-list xmlns:android="http://schemas.android.com/apk/res/android"
android:oneshot="false">
<item android:drawable="@drawable/rocket_thrust1" android:duration="200" />
<item android:drawable="@drawable/rocket_thrust2" android:duration="200" />
<item android:drawable="@drawable/rocket_thrust3" android:duration="200" />
</animation-list>
此应用程序代码将动画设置为视图的背景,然后播放动画:
ImageView rocketImage = (ImageView) findViewById(R.id.rocket_image);
rocketImage.setBackgroundResource(R.drawable.rocket_thrust);
rocketAnimation = (AnimationDrawable) rocketImage.getBackground();
rocketAnimation.start();
在这里你可以使用一套drawables并开始动画,一旦点击了视图,你就可以通过调用 rocketAnimation.stop();
来停止动画