3

私はこれが初めてで、これは私の最初のAndroidプロジェクトであり、ビットマップを機能させる方法を見つけることができないようです。私は本当にこのコードが必要です。オフセットの変更を設定する方法がわかりません。助けが必要です。

ここに私のコードのサンプルがあります

@Override
public void onDestroy() {
    // TODO Auto-generated method stub
    super.onDestroy();
}

@Override
public Engine onCreateEngine() {
    // TODO Auto-generated method stub
    return new SwerveEngine();
}

// ===============================================
// ===============================================

public class SwerveEngine extends Engine implements Runnable {

    float mOffset;
    float xOffset = -480; 
    float yOffset ;
    float xOffsetStep = -240 ;
    float yOffsetStep ; 
    float xPixelOffset = - 480;
    float yPixelOffset ;

    float y = -1;
    float x = -240;
    float mX = -1;
    float mY = -1;
    int dx = 2;
    int dy = 2;
    int radius = 1;

    double gravity = 15;
    double energyloss = .65;
    double dt = .2;

    Bitmap done, bg;

    // private int xOffset;

    public SwerveEngine() {
        // TODO Auto-generated constructor stub
        done = BitmapFactory.decodeResource(getResources(),
                R.drawable.smalllaker);
        bg = BitmapFactory.decodeResource(getResources(),
                R.drawable.lakerpt2);

        // float x = -1*(int)((xOffset*done.getWidth()));
    }

    @Override
    public void onVisibilityChanged(boolean visible) {
    }

    @Override
    public void onCreate(SurfaceHolder surfaceHolder) {
        // TODO Auto-generated method stub
        super.onCreate(surfaceHolder);
    }

    @Override
    public void onOffsetsChanged(float xOffset, float yOffset,
            float xOffsetStep, float yOffsetStep, int xPixelOffset,
            int yPixelOffset) {

        super.onOffsetsChanged(xOffset, yOffset,
                xOffsetStep, yOffsetStep, xPixelOffset, yPixelOffset);

        mOffset = xPixelOffset;
        drawFrame();
    }

    public void setWallpaperOffsetSteps(float xStep, float yStep) {

    }

    @Override
    public void onSurfaceChanged(SurfaceHolder holder, int format,
            int width, int height) {
        // TODO Auto-generated method stub
        super.onSurfaceChanged(holder, format, width, height);

    }

    void drawFrame() {
        final SurfaceHolder holder = getSurfaceHolder();

        Canvas c = null;
        try {
            c = holder.lockCanvas();
            if (c != null)


            c.drawBitmap(bg, mX, c.getHeight()/2, null);
            c.drawBitmap(done, 0, c.getHeight()/2 - 89, null);

        } finally {
            if (c != null)
                holder.unlockCanvasAndPost(c);
        }

    }

    // View arg0,
    public boolean onTouch(MotionEvent arg1) {
        // TODO Auto-generated method stub
        if (arg1.getAction() == MotionEvent.ACTION_MOVE) {
            mX = arg1.getX();
            mY = arg1.getY();
        } else {

            mX = -1;
            mY = -1;
        }

        super.onTouchEvent(arg1);
        return false;
    }

    @Override
    public void run() {
        // TODO Auto-generated method stub

    }

}

@Override
public boolean onTouch(View arg0, MotionEvent arg1) {
    // TODO Auto-generated method stub
    return false;
}

}

ご協力いただきありがとうございます !!

4

0 に答える 0