これは私の完全なコードです,,,,
誰でも私を助けることができます、、、
public class MainActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(new Panel(this));
}
}
class Panel extends SurfaceView implements SurfaceHolder.Callback {
private Bitmap[] mBitmap;
private ViewThread mThread;
public Panel(Context context) {
super(context);
mBitmap = new Bitmap[4];
mBitmap[0] = BitmapFactory.decodeResource(getResources(), R.drawable.x);
mBitmap[1] = BitmapFactory.decodeResource(getResources(), R.drawable.x);
mBitmap[2] = BitmapFactory.decodeResource(getResources(), R.drawable.x);
mBitmap[3] = BitmapFactory.decodeResource(getResources(), R.drawable.x);
getHolder().addCallback(this);
mThread = new ViewThread(this);
}
public void doDraw(Canvas canvas) {
canvas.drawColor(Color.BLACK);
canvas.drawBitmap(mBitmap[0], 0, 0, null);
canvas.drawBitmap(mBitmap[1], 45, 0, null);
canvas.drawBitmap(mBitmap[2], 90, 0, null);
canvas.drawBitmap(mBitmap[3], 135, 0, null);
@Override
public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
// TODO Auto-generated method stub
}
@Override
public void surfaceCreated(SurfaceHolder holder) {
if (!mThread.isAlive()) {
mThread = new ViewThread(this);
mThread.setRunning(true);
mThread.start();
}
}
@Override
public void surfaceDestroyed(SurfaceHolder holder) {
if (mThread.isAlive()) {
mThread.setRunning(false);
}
}
@Override
public boolean onTouchEvent(MotionEvent event) {
mX = (int) event.getX() - mBitmap[0].getWidth() / 2;
mX = (int) event.getX() - mBitmap[1].getWidth() / 2;
mX = (int) event.getX() - mBitmap[2].getWidth() / 2;
mX = (int) event.getX() - mBitmap[3].getWidth() / 2;
return super.onTouchEvent(event);
}
class ViewThread extends Thread {
private Panel mPanel;
private SurfaceHolder mHolder;
private boolean mRun = false;
public ViewThread(Panel panel) {
mPanel = panel;
mHolder = mPanel.getHolder();
}
public void setRunning(boolean run) {
mRun = run;
}
@Override
public void run() {
Canvas canvas = null;
while (mRun) {
canvas = mHolder.lockCanvas();
if (canvas != null) {
mPanel.doDraw(canvas);
mHolder.unlockCanvasAndPost(canvas);
}
}
}
}
ビットマップを左右に 1 つずつ移動する方法
ビットマップが移動する場合、隣接するビットマップ
私のコードで何が間違っていますか?
これを私のコードで解決するには?
私を助けてください