0

ゲームを開発しています。これには、上から下に垂直にスクロールする背景画像が必要です。

実際、私のエミュレータのサイズは 320*720(幅*高さ) ですが、背景画像のサイズは 320*3840 です。したがって、Height: 720 から 3840 までの背景画像のスクロールが必要です。

背景画像をスクロールするコードがありますが、背景画像が正しくスクロールされません。私を助けてください。
ここに私のコードがあります、

        private Bitmap mBackgroundImageFar; //my image
        private int mBGFarMoveY = 0;

                 mBGFarMoveY = mBGFarMoveY + 2;

        int newFarY = mBackgroundImageFar.Height - (- mBGFarMoveY);

        if (newFarY <= 0) 
        {
            mBGFarMoveY =0;
            canvas.DrawBitmap (mBackgroundImageFar,0,mBGFarMoveY,null);
        } 
        else
        {
            canvas.DrawBitmap (mBackgroundImageFar,0,mBGFarMoveY,null);
            canvas.DrawBitmap (mBackgroundImageFar,0,newFarY, null);
        }

書き間違いがありましたら、お許しください。

ありがとうございます、チャクリ。

4

2 に答える 2

1
    private Bitmap mBackgroundImageFar; //my image
    private int mBGFarMoveY = 0;

             mBGFarMoveY = mBGFarMoveY + 2;

    int newFarY = mBackgroundImageFar.Height - (+ mBGFarMoveY);

    if (newFarY <= 0) 
    {
        mBGFarMoveY =0;
        canvas.DrawBitmap (mBackgroundImageFar,0,mBGFarMoveY,null);
    } 
    else
    {
        canvas.DrawBitmap (mBackgroundImageFar,0,mBGFarMoveY,null);
        canvas.DrawBitmap (mBackgroundImageFar,newFarY,0, null);
    }
于 2012-10-17T12:03:01.467 に答える
1

ゲームエンジンを使用していますか?問題を解決する簡単な方法は、ゲーム エンジンを使用することです。たとえば、andengine で解決するの、 CameraScene または ParallaxBackground です。

于 2012-07-17T09:30:28.087 に答える