我需要为动画渲染设计一个组件。因为你可能比我聪明得多,所以我问你的opinion.How,你会做下面的设计吗?
更确切地说,我想要一匹能跑、能停、能跳、能闪的马。我可以获得所有这些状态所需的所有帧。例如,我可以绘制包含奔跑的马的所有帧(f1- fn)。但是如果马在fk帧(1 )上奔跑时需要躲避怎么办?
如何设计这种类型的转换?您将使用哪些类?是否需要为每个fk绘制过渡
更多细节如果有帮助:设计将在Android SDK中实现。
非常感谢!
发布于 2015-09-21 22:32:22
请尝试以下代码。希望它能起作用
您需要在res/drawable下创建动画列表
<?xml version="1.0" encoding="utf-8"?>
<animation-list xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/animationFrame"
android:oneshot="false" >
<item
android:drawable="@drawable/es0"
android:duration="100"/>
<item
android:drawable="@drawable/es1"
android:duration="100"/>
<item
android:drawable="@drawable/es2"
android:duration="100"/>
<item
android:drawable="@drawable/es3"
android:duration="100"/>
<item
android:drawable="@drawable/es4"
android:duration="100"/>
</animation-list>在activity中编写以下代码
private AnimationDrawable m_frameAnimation = new AnimationDrawable();
imageView.setBackgroundResource(R.drawable.animationFrame);
m_frameAnimation = (AnimationDrawable) imageView.getBackground();
m_frameAnimation.start();https://stackoverflow.com/questions/32697225
复制相似问题