前一篇說了實現過程,這次來寫一個自己簡單實現的3d動畫
,方便使用xml 檔案來定製動畫
配置參數相關的一些解釋
dimension 像素實值型別,包括有"px", "dip", "sp", "pt", "in", "mm", 一般用TypedValue.complexToDimension解析
fraction 分數,一般用來表示占的百分比,"%", "%p"。 一般用TypedValue.complexToFraction解析 有時候和float類型功能通用
float 浮點數。當確定是這個類型的時候,用TypedValue.getFloat解析
integer 整數,TypedValue.data 就是這個值。
動畫配置
包
CubeAnimation mFromXType = mFromX = 0 mFromXdata = 0 mToXType = mToX = 0 mToXData = 0 mAxisY = 0 mAxisYType = CubeAnimation( fromX, toX, fromDegree, toDegree,.mFromX =.mToX =.mFromDegrees =.mToDegrees =.mAxisY =======(value.type==.mFromX =.mFromXType =.mFromXType =.mFromXdata ==(value.type==TypedValue.TYPE_FLOAT){ .mToX =.mToXType =.mToXType =.mToXData = t = a.getBoolean(R.styleable.CubeAnimation_positive, (!.mToDegrees = 0.0F.mFromDegrees = 90.0F.mFromDegrees = a.getFloat(R.styleable.CubeAnimation_fromDegree, 0.mToDegrees = a.getFloat(R.styleable.CubeAnimation_toDegree, 90=.mAxisYType = (.mAxisYType==.mAxisY =.mAxisYType =.mAxisY = initialize( width, height, (.mFromXType!=TypedValue.TYPE_FLOAT){ .mFromX = resolveData(.mFromXType,(mToXType!=.mToX = resolveData(.mToXType,.mCamera = (mAxisYType==RELATIVE_TO_SELF) { mAxisY = mAxisY*"mFromX="+mFromX+",mToX=="+ resolveData( type, data, size, value = 0 (type === (type ==={ value= applyTransformation( fromDegrees = degrees = fromDegrees + (.mToDegrees -*= =+(mToX-mFromX)*interpolatedTime, Animation loadAnimation(Context context, = = createAnimationFromXml(context, parser, = "Can't load animation resource ID #0x" += "Can't load animation resource ID #0x" + (parser != = depth = (((type = parser.next()) != XmlPullParser.END_TAG ||> depth) && type != (type !== (name.equals("set"= (name.equals("alpha"= (name.equals("scale"= (name.equals("rotate"= (name.equals("translate"= (name.equals("cube"= "not a cubeanimation animation name: " + (parent != View Code
設定檔載入和動態構造兩種方式建立對話執行個體以及調用
AnimateActivity = (v.getTag()==||"設定檔載入"="動態初始化"= CubeAnimation(0, 400, 0, 360, 1008000View Code
ok 基本完成,希望沒有什麼遺漏