1. Are you ready for the Galaxy S20? Here is everything we know so far!

sprite drawing problem

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

  1. tneva82

    tneva82 Newbie
    Thread Starter

    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...
     


Loading...
Similar Threads - sprite drawing problem
  1. Rad Brothers
    Replies:
    1
    Views:
    658
  2. App Update
    Replies:
    0
    Views:
    101
  3. App Update
    Replies:
    0
    Views:
    94
  4. The_Chief
    Replies:
    7
    Views:
    980
  5. Muffi Zainu
    Replies:
    18
    Views:
    4,965
  6. Phrozt
    Replies:
    1
    Views:
    263
  7. Kevin Barnes
    Replies:
    1
    Views:
    218
  8. ClintonBrits
    Replies:
    0
    Views:
    370
  9. Valera_1987_01
    Replies:
    1
    Views:
    495
  10. lawfx
    Replies:
    0
    Views:
    776

Share This Page

Loading...