2

On touch i create and move a bitmap. Now I want to scale the bitmap while i move it. How do i bring this effect ? Im using a sprite object to move it. I want to create an illusion of shooting . I guess this shall be achieved by the logic.

public class SpriteObject {

    private Bitmap bitmap;
    private int x;      
    private int y;  
    private int x_move = 0;
    private int y_move = -1;


    public SpriteObject(Bitmap bitmap, int x, int y) {
        this.bitmap = bitmap;
        this.x = x;
        this.y = y;
    }


    public int getX() {
        return x;
    }

    public int getY() {
        return y;
    }

    public Bitmap getBitmap() {
        return bitmap;
    }


    public void setMoveX(int movex){
        x_move = movex;
    }
    public void setMoveY(int movey){
        y_move = movey;
    }
    public void setX(int x) {
        this.x = x;
    }

    public void setY(int y) {
        this.y = y;
    }
    public void setBitmap(Bitmap bitmap) {
        this.bitmap = bitmap;
    }

    public void draw(Canvas canvas) {
        canvas.drawBitmap(bitmap, x - (bitmap.getWidth() / 2), y - (bitmap.getHeight() / 2), null);
    }

    public void update(int adj_mov) {
            x += (adj_mov * x_move);
            y += (adj_mov * y_move);

    }
    public void still(int adj_still) {
        x += (adj_still * x_move);
        y += (adj_still * y_move);

    }


}
Carnal
  • 21,744
  • 6
  • 60
  • 75
koherent
  • 370
  • 1
  • 3
  • 19

1 Answers1

0

Please try this:

int h = 100; // height in pixels
int w = 100; // width in pixels

Bitmap photoBitmap = Bitmap.createScaledBitmap(yourSelectedImageBitmap, h, w,true);
Adi Inbar
  • 12,097
  • 13
  • 56
  • 69
nilesh patel
  • 834
  • 1
  • 5
  • 10