2012-03-04 235 views
0

我想能夠旋轉也是動畫的移動精靈(atm在一行中有3個圖像)。我將如何去做這件事?旋轉動畫雪碧?

當前精靈在屏幕上移動並旋轉。

到目前爲止,我得到這個代碼:(但它看起來很亂)

this._rect = new Rect(0,0, this._spriteWidth, this._spriteHeight); 

    //this._rect.left = 1 * this._spriteWidth; 
    //this._rect.right = this._rect.left + this._spriteWidth; 

    //What the bitmap will be fitted into. 
    Rect dest = new Rect(current_Position.x, current_Position.y, current_Position.x + this._spriteWidth, current_Position.y + this._spriteHeight); 

    mMatrix.reset(); 
    mMatrix.postRotate(Degrees, _spriteWidth/3, _spriteHeight/2); 
    mMatrix.postTranslate(current_Position.x, current_Position.y); 

    this._modified_bitmap = Bitmap.createBitmap(_bitmap, 0, 0, _bitmap.getWidth(), _bitmap.getHeight(), mMatrix, false); 

    canvas.drawBitmap(_modified_bitmap, _rect, dest, null); 

任何人的幫助的感謝?

---解決(雖然如果有人知道一個更有效的方式請讓我知道)---

mMatrix.reset(); 
    mMatrix.postRotate(Degrees, _spriteWidth/3, _spriteHeight/2); 
    mMatrix.postTranslate(current_Position.x, current_Position.y); 

    this._modified_bitmap = Bitmap.createBitmap(_bitmap, 0, 0, _spriteWidth, _spriteHeight); 

    canvas.drawBitmap(_modified_bitmap, mMatrix, null); 

回答

0

---解決(雖然如果有人知道一個更有效的方式請讓我知道) ---

mMatrix.reset(); 
mMatrix.postRotate(Degrees, _spriteWidth/3, _spriteHeight/2); 
mMatrix.postTranslate(current_Position.x, current_Position.y); 

this._modified_bitmap = Bitmap.createBitmap(_bitmap, 0, 0, _spriteWidth, _spriteHeight); 

canvas.drawBitmap(_modified_bitmap, mMatrix, null);