Повернуть анимированный спрайт? - PullRequest
0 голосов
/ 04 марта 2012

Я хочу иметь возможность вращать движущийся спрайт, который также анимирован (у АТМ есть 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);

1 Ответ

0 голосов
/ 04 апреля 2012

--- Решено (хотя, если кто-нибудь знает более эффективный способ, пожалуйста, дайте мне знать) ---

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);
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...