哟。我在尝试生成签名的apk时遇到此错误。这是怎么回事 该类应提供默认构造函数(不带参数的公共构造函数) 如何在我的代码中修复此问题? 包com.deejaykingsteve.kingsblastfighter
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Rect;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
public class king {
private Bitmap bitmap;
private int x;
private int y;
private int speed = 0;
private boolean boosting;
private final int GRAVITY = -10;
private int maxY;
private int minY;
private final int MIN_SPEED = 1;
private final int MAX_SPEED = 20;
private Rect detectCollision;
public king(Context context, int screenX, int screenY) {
x = 75;
y = 50;
speed = 1;
bitmap =
BitmapFactory.decodeResource(context.getResources(),
R.drawable.king);
maxY = screenY - bitmap.getHeight();
minY = 0;
boosting = false;
detectCollision = new Rect(x, y, bitmap.getWidth(),
bitmap.getHeight());
}
public void setBoosting() {
boosting = true;
}
public void stopBoosting() {
boosting = false;
}
public void update(){
if (boosting) {
speed += 3;
} else {
speed -= 4;
}
if (speed > MAX_SPEED) {
speed = MAX_SPEED;
}
if (speed < MIN_SPEED) {
speed = MIN_SPEED;
}
y -= speed + GRAVITY;
if (y < minY) {
y = minY;
}
if (y > maxY) {
y = maxY;
}
detectCollision.left = x;
detectCollision.top = y;
detectCollision.right = x + bitmap.getWidth();
detectCollision.bottom = y + bitmap.getHeight();
}
public Rect getDetectCollision() {
return detectCollision;
}
public Bitmap getBitmap() {
return bitmap;
}
public int getX() {
return x;
}
public int getY() {
return y;
}
public int getSpeed() {
return speed;
}
}
答案 0 :(得分:0)
通过最少的研究,这样的事情不会在这里提出来!
示例:
public class StackOverflow{
public StackOverflow(){ // here you have the public constructor with no argument
}
}