Download the free trial version
Basic4android Video
Features
Tutorials and manuals
Showcase
Screenshots

Go Back   Android Development Forum - Basic4android > Basic4ppc (Windows Mobile) > Questions (Windows Mobile)
Documentation Wiki Register Members List B4P Search Today's Posts Mark Forums Read

Questions (Windows Mobile) 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: 15,733
Awards Showcase
Basic4ppc Founder 
Total Awards: 1
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 Off
Pingbacks are Off
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Walking character using the Sprite library Erel Code Samples & Tips 5 05-14-2010 04:22 AM
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
Library folder question to Erel agraham Questions (Windows Mobile) 6 11-11-2007 04:27 PM


All times are GMT. The time now is 08:59 AM.


Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0