This is my code for in the Sprite class:
public class Sprite {
int x, y, vx, vy;
private Bitmap texture;
public Sprite(Bitmap texture) {
this.texture = texture;
}
public int getWidth() {
return texture.getWidth();
}
public int getHeight() {
return texture.getHeight();
}
public void draw(Canvas c) {
c.drawBitmap(texture, x, y, null);
}
}
and with background.draw(c); I draw a background. But the background is bigger than the screen…
How can I scale it to the size of the screen ?
You are setting only the left and top properties of the bitmap when drawing it. To scale it, call an overload drawBitmap method with width and height, like this one
To give you the idea:
In the Activity where you create the class Sprite you must do something like: