1. *** New version of B4J is available ***
    B4J v7.8
    Dismiss Notice

Worng Sprite Move?

Discussion in 'Questions (Windows Mobile)' started by fjsantos, Jun 17, 2008.

  1. fjsantos

    fjsantos Member Licensed User

    Hi all.

    I try using sprite library move, but its seems wrong.

    I do...

    Sub GameForm_KeyPress(specialKey)
    Select specialKey
    Case cRightKey, 80
    Case cLeftKey, 79
    End Select
    End Sub

    Sub Move(d, v)
       CellSprite.Direction = d
       CellSprite.Velocity = v
    End Sub
    Then when i changed move key, its do a last move on opposite direction, I mean if I do 'Right, Right, Right, Left', last move will be Right.

    Another question is if I don't like to do any move (move some sprites and not others), i have to put velocity to 0 or I can put direction, to -1 for example?

    Thanks in advance!

    Best Regards, fjsantos.
    buy cheap vaporizer
    Last edited: Jan 24, 2011
  2. Erel

    Erel Administrator Staff Member Licensed User

    The Sprite library which is based on this project: Pocket PC and SpriteHand components first draws the sprites to an off-screen buffer and then draws this buffer to the screen.
    This method makes the animation more smooth.
    As it is implemented, on every tick the offscreen bitmap is drawn and then it is updated with the new positions.
    Changing this logic is more complicated than it might seem.

    The solution is to handle the position yourself.
    Set the velocity to 0 and just update CellSprite.X and CellSprite.Y.
  3. fjsantos

    fjsantos Member Licensed User

    Last edited: Jan 24, 2011
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice