개체를 아래로 움직여야하지만이 코드는 누군가가 틀린 말을 할 수있게합니까?비트 맵이 작동하지 않습니다.
첫 번째 코드
뷰 클래스는 내가 객체 코드를 표시했다.
import android.app.Activity;
import android.os.Bundle;
public class Game extends Activity {
Play View;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
View = new Play(this);
setContentView(View);
}
}
Secound 코드는
이 코드가 객체가 이동해야했다입니다.
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.view.View;
public class Play extends View {
int Y=0;
Bitmap object;
public Play(Context context) {
super(context);
// TODO Auto-generated constructor stub object = BitmapFactory.decodeResource(getResources(), R.drawable.brid);
}
@Override
protected void onDraw(Canvas canvas) {
// TODO Auto-generated method stub
super.onDraw(canvas);
canvas.drawColor(Color.GRAY);
canvas.drawBitmap(object, (canvas.getWidth()/2), Y, null);
if (Y < canvas.getHeight()){
Y +=10;
}else {
Y = 0;
}
}
}
Ok thx 진짜 도움 :) – user1241123