Y
YouKnowNow
Neues Mitglied
- 0
ich hab ein Problem undzwar Das :
GameView.java
GameView.java
Code:
package com.youknownow.panjutorials;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.view.Surface;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.view.View;
/**
* Created by abbas on 26.09.2016.
*/
public class GameView extends SurfaceView {
private SurfaceHolder surfaceHolder;
private Bitmap bmp;
private int y=0;
private GameLoopThread theGameLoopThread;
public GameView(Context context) {
super(context);
theGameLoopThread = new GameLoopThread(this);
surfaceHolder = getHolder();
surfaceHolder.addCallback(new SurfaceHolder.Callback() {
[USER=3517]@override[/USER]
public void surfaceCreated(SurfaceHolder holder) {
theGameLoopThread.setRunning(true);
theGameLoopThread.start();
}
[USER=3517]@override[/USER]
public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
}
@override
public void surfaceDestroyed(SurfaceHolder holder) {
boolean retry = true;
theGameLoopThread.setRunning(false);
while (retry){
try {
theGameLoopThread.join();
retry = false;
}catch (InterruptedException e){
}
}
};
});
bmp = BitmapFactory.decodeResource(getResources(),R.mipmap.ic_launcher);}
protected void onDraw(Canvas canvas){
canvas.drawColor(Color.GREEN);
if (y <= getHeight() = bmp.getHeight()) { rot unterstrichen: required:booelan
y=y+3; find int
}
canvas.drawBitmap(bmp, 25, y, null);
}
}
Zuletzt bearbeitet von einem Moderator: