我的舱位和星体为后一类,当时我正在确定一些功能,以计算布贝莱斯在屏幕上的动议。
public class floatBubble {
private Bitmap img; // the image of the ball
private int coordX = 512; // the x coordinate at the canvas
private int coordY = 600; // the y coordinate at the canvas
private int id; // gives every ball his own id, for now not necessary
private static int count = 1;
private boolean goRight = true;
private boolean goDown = true;
public floatBubble(Context context, int drawable) {
BitmapFactory.Options opts = new BitmapFactory.Options();
opts.inJustDecodeBounds = true;
img = BitmapFactory.decodeResource(context.getResources(), drawable);
id=count;
count++;
}
public static int getCount() {
return count;
}
void setX(int newValue) {
coordX = newValue;
}
public int getX() {
return coordX;
}
void setY(int newValue) {
coordY = newValue;
}
public int getY() {
return coordY;
}
public int getID() {
return id;
}
public Bitmap getBitmap() {
return img;
}
public void moveBall(int goX, int goY) {
// check the borders, and set the direction if a border has reached
if (coordX > 1024){
goRight = false;
}
if (coordX < -100){
goRight = false;
coordX = 512;
coordY = 600;
}
if (coordY > 600){
goDown = false;
}
if (coordY < -100){
coordY = 600;
goDown = false;
}
// move the x and y
if (goRight){
coordX += goX;
}else
{
coordX -= goX;
}
if (goDown){
coordY += goY;
}else
{
coordY -= goY;
}
}
}
第1024*600px号决议。 BUt I想要计算在运行时间的屏幕。 A. 界定 co的手段 页: 1 Y在业时间。 你能够帮助我修改法典。
我试图在我的行车(Ball())中使用以下守则,但该守则在那里工作。
DisplayMetrics dm = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(dm);
coordX = dm.widthPixels;
coordY = dm.heightPixels;
任何人都可以提出解决办法?