Sprite Library question

Discussion in 'Questions (Windows Mobile)' started by Leginus, Mar 12, 2008.

  1. Leginus

    Leginus Member Licensed User

    I have a stationary sprite in the middle of the screen and other sprites falling from the top of the screen to the bottom(using sprite direction and velocity). When a sprite collides with the sprite in the middle of the screen I try to move the colliding sprite to the right until the collision is over. However, the collision routine moves both the colliding sprite and the sprite in the middle when using this code

    Sub gw_Collision
        Spr1.Value = gw.Sprite1 
        spr2.Value = gw.Sprite2
    End Sub
    Is this a bug with the sprite library, e.g. that is cannot differentiate between spr1.x and spr2.x, or am I missing the point somewhere

  2. Erel

    Erel Administrator Staff Member Licensed User

    If I understand correctly this code will run several times in each set of collisions.
    The order of the sprites (gw.Sprite1 and gw.Sprite2) can be different each time and therefore cause both sprites to move.
    The best solution is to bind the stationary sprite to one object and use this object to move it:
    Sub gw_Collision
    If gw.SpriteIndex(spr1.Value) = IndexOfSpecialSprite OR gw.SpriteIndex(spr2.Value) = IndexOfSpecialSprite Then
      SpecialSprite.x = SpecialSprite.x + 
    End If
    End Sub
  3. Leginus

    Leginus Member Licensed User

    Thanks Erel I will give that a try
  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