1. Download our Official Android App: Forums for Android!

Apps sprite drawing problem

Discussion in 'Android Development' started by tneva82, May 8, 2012.

  1. tneva82

    tneva82 Member
    Thread Starter
    Rank:
    None
    Points:
    15
    Posts:
    31
    Joined:
    Jun 20, 2011

    Jun 20, 2011
    31
    0
    15
    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...
     

    Advertisement

Share This Page

Loading...