Rotation of pictures



  • Can't anyone tell us how to turn the image on java? I wanted to use it.

    canvas.save();
    canvas.rotate(angle);
    canvas.drawBitmap(player, x, y, null);
    canvas.restore();
    

    But somehow it doesn't respond. I need the image to turn around all the time.

    UPDATE:

    Finding a working example

    class Car {
        final Matrix transform = new Matrix();
        final Bitmap image;
    
    Car(Bitmap sprite) {
        image = sprite;  // Created by BitmapFactory.decodeResource in SurfaceView
    }
    void update() {
        this.transform.preRotate(turnDegrees, width, height);
    }
    void display(Canvas canvas) {
        canvas.drawBitmap(this.image, this.transform, null);
    }
    

    }

    But it's really cool, not around its axis, but around the sky knows what?



  • If animation is done for Androids, you can try. http://developer.android.com/guide/topics/graphics/view-animation.html#tween-animation

    You can use the view animation system to perform tweened animation on Views. Tween animation calculates the animation with information such as the start point, end point, size, rotation, and other common aspects of animation.

    The spinning of the holding can be done:

    Matrix m = new Matrix();
    

    m.setTranslate(centerX, centerY);
    m.preRotate(angle, width/2, height/2);

    canvas.drawBitmap(bitmap, m, null);




Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2