Basic4ppc - Windows Mobile Development  

Go Back   Basic4ppc - Windows Mobile Development > Main Category > Questions & Help Needed
Home Register FAQ Members List Search Today's Posts Mark Forums Read

Questions & Help Needed Post any question regarding Basic4ppc.


Sprite Library question


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-12-2008, 11:43 PM
Junior Member
 
Join Date: Dec 2007
Posts: 27
Default Sprite Library question

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

Code:
Sub gw_Collision
    Spr1.Value = gw.Sprite1 
    spr2.Value = gw.Sprite2
    spr2.x=spr2.x+1
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

thanks
Leginus
Reply With Quote
  #2 (permalink)  
Old 03-13-2008, 06:26 AM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 2,954
Default

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:
Code:
Sub gw_Collision
  If gw.SpriteIndex(spr1.Value) = IndexOfSpecialSprite OR gw.SpriteIndex(spr2.Value) = IndexOfSpecialSprite Then
  SpecialSprite.x = SpecialSprite.x + 1
 End If
End Sub
Reply With Quote
  #3 (permalink)  
Old 03-13-2008, 10:15 AM
Junior Member
 
Join Date: Dec 2007
Posts: 27
Default

Thanks Erel I will give that a try
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Sprite library - V1.1 Erel Official Updates 0 02-28-2008 03:45 PM
New Sprite library Erel Official Updates 4 02-22-2008 03:00 PM
New Sprite library Erel Announcements 2 01-24-2008 07:38 PM
Walking character using the Sprite library Erel Code Samples & Tips 2 01-18-2008 05:46 PM
Library folder question to Erel agraham Questions & Help Needed 6 11-11-2007 04:27 PM


All times are GMT. The time now is 06:24 PM.


Powered by vBulletin® Version 3.6.10
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.1.0