Scrolling Game Development Kit Forum
SGDK Version 2 => Help, Errors, FAQ => Topic started by: Jam0864 on 2009-01-26, 05:55:04 AM
-
Just having trouble with the collision detection between two sprites.
What I'm doing is having a rule in one of the sprites,
Do TestCollisionMask
Target: ParentLayer.m_SpriteCategories.Cursor
Output To: Counter.ButtonCollide.CurrentValue
What I assumed from the hint given in the yellow text area,
Determine whether the sprite's collision mask is overlapping part of any sprite in the specified category. Return the index of the sprite within the category if a collision is occurring, otherwise return -1.
that I simply link it to a counter, then make a rule
if ButtonCollide = 0
do...
If ButtonCollide = 1
do...
If ButtonCollide = 2
do...
(all for different sprites in the category)
but it appears the counters cannot go below 0, so the -1 that's supposed to be being outputted is actually rounding to 0, which is the index of the sprite in the category I'm trying to detect collisions with, so I cannot differ between not touching and touching. What am I doing wrong here?
-
Use some temporary variable or create a sprite parameter to hold the result if you don't have one.
-
What's a temporary variable and how do I make/use one?
Thanks, the sprite parameter worked.
-
I think if you're using the plan editor, there's a temporary variable called "sharedTemp1" or something. Basically, you can manually declare any variable you want in the code editor in PlanBase or SpriteBase, and then use it in the rule editor. I think PlanBase has one already set up. But a sprite parameter is easier.