Tween动画xml

package Tween.yb;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.drawable.BitmapDrawable;
import android.view.KeyEvent;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;

/**
 * @author yubin
 * @version 2012-8-16 下午02:25:19
 **/
public class myGameView extends View {
    // 渐变透明
    private Animation mAnimationAlpha = null;
    // 渐变尺寸伸缩
    private Animation mAnimationScale = null;
    // 渐变位置移动
    private Animation mAnimationTranslate = null;
    // 渐变画面旋转
    private Animation mAnimationRotate = null;

    Bitmap bitmap = null;
    Context context = null;

    public myGameView(Context context) {
        super(context);
        bitmap = ((BitmapDrawable) getResources().getDrawable(R.drawable.icon))
                .getBitmap();
        // 设置焦点 就可以使用onKeyDown
        setFocusable(true);
        this.context = context;
    }

    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        switch(keyCode) {
            case KeyEvent.KEYCODE_DPAD_UP:
                mAnimationAlpha = AnimationUtils.loadAnimation(context,
                        R.anim.alpha);
                startAnimation(mAnimationAlpha);
                break;
            case KeyEvent.KEYCODE_DPAD_DOWN:

                mAnimationScale = AnimationUtils.loadAnimation(context,
                        R.anim.scale);
                startAnimation(mAnimationScale);
                break;
            case KeyEvent.KEYCODE_DPAD_LEFT:
                mAnimationTranslate = AnimationUtils.loadAnimation(context,
                        R.anim.translate);
                startAnimation(mAnimationTranslate);
                break;
            case KeyEvent.KEYCODE_DPAD_RIGHT:

                mAnimationRotate = AnimationUtils.loadAnimation(context,
                        R.anim.rotate);
                startAnimation(mAnimationRotate);
                break;
        }
        return super.onKeyDown(keyCode, event);
    }

    @Override
    protected void onDraw(Canvas canvas) {
        // TODO Auto-generated method stub
        super.onDraw(canvas);
        canvas.drawBitmap(bitmap, 0, 0, null);
    }
}
alpha
<?xml version="1.0" encoding="utf-8"?>
<alpha
	xmlns:android="http://schemas.android.com/apk/res/android"
	android:fromAlpha="0.1"
	android:toAlpha="1.0"
	android:duration="2000">
</alpha>
rotate
<?xml version="1.0" encoding="utf-8"?>
<rotate
	xmlns:android="http://schemas.android.com/apk/res/android"
	android:interpolator="@android:anim/accelerate_decelerate_interpolator"
	android:fromDegrees="0"
	android:toDegrees="360"
	android:pivotX="0.5"
	android:pivotY="0.5"
	android:duration="1000">
</rotate>
scale
<?xml version="1.0" encoding="utf-8"?>
<scale
	xmlns:android="http://schemas.android.com/apk/res/android"
	android:interpolator="@android:anim/accelerate_decelerate_interpolator"
	android:fromXScale="0.0"
	android:toXScale="1.0"
	android:fromYScale="0.0"
	android:toYScale="1.0"
	android:pivotX="50%"
	android:pivotY="50%"
	android:fillAfter="false"
	android:duration="500">
</scale>
translate
<?xml version="1.0" encoding="utf-8"?>
<translate
	xmlns:android="http://schemas.android.com/apk/res/android"
	android:fromXDelta="10"
	android:toXDelta="100"
	android:fromYDelta="10"
	android:toYDelta="100"
	android:duration="1000">
</translate>



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值