Reputation: 123
I am developing a game. In this I need background image scrolling vertically from top to bottom.
Actually my emulator size is 320*720(width*height) but my background image size is 320*3840. So now I need background image scroll from Height: 720 to 3840.
I have code for a background image scrolling but background image not scrolling properly. Please help me.
Here is my code,
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);
}
If I write any mistakes please excuse me.
Thanks & Regard's, Chakri.
Upvotes: 0
Views: 1840
Reputation: 123
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);
}
Upvotes: 1