- Code: Select all
package game.testScroller;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Paint;
public class GroundPiece {
private Context context;
Resources res = context.getResources();
private int x;
private int y;
private Paint groundPiecePaint;
private Bitmap groundPiecePic = BitmapFactory.decodeResource(res, R.drawable.groundpiece);
public GroundPiece(int x, int y){
this.x = x;
this.y = y;
}
public void setX(int x){
this.x = x;
}
public int getX(){
return x;
}
public void setY(int y){
this.y = y;
}
public int getY(){
return y;
}
public void moveLeft(){
this.x -= 5;
}
public void moveRight(){
this.x += 5;
}
public void moveUp(){
this.y -= 5;
}
public void moveDown(){
this.y += 5;
}
public void draw(Canvas c){
c.drawBitmap(groundPiecePic, getX(), getY(), groundPiecePaint);
}
}


