• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps sprite drawing problem

tneva82

Newbie
Practicing bit of sprite drawing. Trying to get basically tile map(yeah yeah. straight from '80's!) working. However for some reason only part of the bitmap is drawn???

Drawing code:

public void Update(long GameTime) {
if(GameTime > mFrameTimer + mFPS ) {
mFrameTimer = GameTime;
mCurrentFrame +=1;

if(mCurrentFrame >= mNoOfFrames) {
mCurrentFrame = 0;
}
}

mSRectangle.left = mCurrentFrame * mSpriteWidth;
mSRectangle.right = mSRectangle.left + mSpriteWidth;
}

public void draw(Canvas canvas, int x, int y) {
Rect dest = new Rect(x*mSpriteWidth, y*mSpriteHeight, (x*mSpriteWidth)+mSpriteWidth,
(y*mSpriteHeight)+mSpriteHeight);

canvas.drawBitmap(mAnimation, mSRectangle, dest, null);
}

First function should give proper frame from animation and second then SHOULD draw it. sprite's width and height both 40 and I have triple checked that the image IS 40x40 picture. x and y indicate which tile I'm drawing from which x/y co-ordinate for top-left is calculated.

But for some reason part of the image is missing. Look like it only draws top-left quarter of the picture.

Feels like it's something really, really simple I'm missing here...
 
Back
Top Bottom