3
我知道如何通過移動/調整UIView來實現基本動畫。但是,以下兩個動畫看起來有點複雜。在iPhone SDK上實現動畫的最佳方法?
1)想象一下汽車遊戲,當你按下踏板按鈕時,速度計旋轉。如何做圓形的酒吧「填滿」的動畫?
2)第二個動畫更容易描述。如何進行數字動畫的增加,其中數字向下滑動,新數字從頂部出現,類似於老虎機。
我知道如何通過移動/調整UIView來實現基本動畫。但是,以下兩個動畫看起來有點複雜。在iPhone SDK上實現動畫的最佳方法?
1)想象一下汽車遊戲,當你按下踏板按鈕時,速度計旋轉。如何做圓形的酒吧「填滿」的動畫?
2)第二個動畫更容易描述。如何進行數字動畫的增加,其中數字向下滑動,新數字從頂部出現,類似於老虎機。
對於你的第一個問題,我會認爲CGAffineTransform會是一條路。利用這一點,我想這樣的事情可以工作:
// BarView is a derived class from UIView that knows how to draw a "bar"
BarView view[NumBars];
for(int i = 0; i < NumBars; i++)
{
// First place the view at the center of the instrument
[view[i] setCenter:CGPointMake(InstrumentX, InstrumentY)];
// Now translate the view InstrumentWidth units on the positive X-Axis
CGAffineTransform translate = CGAffineTransformMakeTranslation(InstrumentWidth, 0);
// Rotate the view about the origin by an angle related to which "bar" this is
CGAffineTransform rotate = CGAffineTransformMakeRotation(i*AngleBetweenBars);
// create a transform matrix from the translation and rotation matrices and apply it to the view
[view[i] setTransform:CGAffineTransformConcat(translate, rotate)];
}
我與CGAffineTransform專家,但沒有這個代碼只是繪製酒吧以循環的方式?它實際上在動畫中點亮了圓周上的酒吧嗎? – erotsppa 2009-06-09 20:16:19