这是错误。
FastRenderView.java
package framework.impl;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Rect;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import framework.Game;
public class FastRenderView extends SurfaceView implements Runnable {
Game game;
Bitmap frameBuffer;
Thread renderThread = null;
SurfaceHolder holder;
volatile boolean running = false;
public FastRenderView(Game game, Bitmap frameBuffer) {
super(game);
this.game = game;
this.frameBuffer = frameBuffer;
this.holder = getHolder();
}
@Override
public void run() {
Rect dstRect = new Rect();
long startTime = System.nanoTime();
while(running) {
if(!holder.getSurface().isValid()) {
continue;
}
float deltaTime = (System.nanoTime() - startTime) / 1000000000.0f;
startTime = System.nanoTime();
game.getScreen().update(deltaTime);
game.getScreen().present(deltaTime);
Canvas canvas = holder.lockCanvas();
canvas.getClipBounds(dstRect);
canvas.drawBitmap(frameBuffer, null, dstRect, null);
holder.unlockCanvasAndPost(canvas);
}
}
public void resume() {
running = true;
renderThread = new Thread(this);
renderThread.start();
}
public void pause() {
running = false;
while(true) {
try {
renderThread.join();
break;
} catch(Exception e) {
// retry
}
}
}
}
问题是在第19行我得到了上面显示的'超级(游戏);'
问题是如何解决这个问题?
如果您需要更多信息,请告诉我!!!
感谢您的帮助!
答案 0 :(得分:1)
当你调用super()时,你将游戏对象传递给父构造函数,这是SurfaceView的构造函数。 SurfaceView实现的唯一单参数构造函数采用Context对象。 Game类是否继承自继承链中的Context?
如果不是,那就是你的问题。如果是,请发布Game类的代码。