0 android showdialog android-animation
我创建了一个模拟爆炸的动画:带有此动画的"booom"图像:
blast.xml HyperspaceExplosion on Activity
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false">
<scale
android:interpolator="@android:anim/bounce_interpolator"
android:fromXScale="1.0"
android:toXScale="2.0"
android:fromYScale="1.0"
android:toYScale="2.5"
android:pivotX="50%"
android:pivotY="50%"
android:fillAfter="false"
android:fillBefore="false"
android:duration="3000"
/>
</set>
Run Code Online (Sandbox Code Playgroud)
当玩家点击炸弹爆炸开始时.在爆炸结束时,我想打开一个Dialog.
炸弹行为的简单代码:
getBombImage().setOnClickListener(
new View.OnClickListener() {
MediaPlayer mp = null;
@Override
public void onClick(View v) {
getExplosionImage().setVisibility(View.VISIBLE);
if(!isSoundOff()){
mp = MediaPlayer.create(getApplicationContext(), R.raw.explosion);
mp.start();
}
getExplosionImage().startAnimation(getHyperspaceExplosion());
getExplosionImage().setVisibility(View.INVISIBLE);
showDialog(1);
}
}
);
Run Code Online (Sandbox Code Playgroud)
问题是爆炸和对话在时间上是冲突的,并且在对话框打开后爆炸继续.
我想要两个事件:在爆炸之前.在爆炸结束时,我想打开对话框.
有人帮我吗?
谢谢你的建议.
小智 7
使用AnimationListener并在里面打开对话框onAnimationEnd().
例如这样:
Animation a = getHyperspaceExplosion();
a.setAnimationListener(new AnimationListener() {
public void onAnimationEnd(Animation animation) {
showDialog(1);
}
// ..other listener methods here..
});
getExplosionImage().startAnimation(a);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1969 次 |
| 最近记录: |