SetDisplayAspect(1)
SetWindowSize(600, 600, 0)
sprite as integer[2]
for k = 0 to 2
sprite[k] = CreateSprite( 0 )
SetSpriteSize( sprite[k], 10, 10 )
SetSpriteOffset( sprite[k], 5, 5 )
SetSpriteColor( sprite[k], (k=0)*255,(k=1)*255, (k=2)*255, 255 )
next k
SetSpritePositionByOffset( sprite[0], 30, 50 )
SetSpritePositionByOffset( sprite[1], 70, 50 )
x = 0
do
print( "Collision: " + str(GetSpriteCollision( sprite[1], Sprite[0] )))
print( "Hit : " + str(GetSpriteHit( GetSpriteX( sprite[2] ), GetSpriteY( Sprite[2] ))))
SetSpritePositionByOffset( sprite[2], 50 + sin(x)*45, 50 )
inc x
sync()
loop
If you run the code above you will get a display telling which sprite has been hit at the position of the moving sprite. Which is great.
However, if you comment out this line:
print( "Collision: " + str(GetSpriteCollision( sprite[1], Sprite[0] )))
Then the hit isn't registered at all.
Uncomment it again and the line below it registers a hit. However, if you change the line so that the moving sprite is checked for a collision with the static sprites then GetSpriteCollision() works as expected but GetSpriteHit() only registers the sprite in the GetSpriteCollision() code.
So, this:
print( "Collision: " + str(GetSpriteCollision( sprite[2], Sprite[0] )))
print( "Hit : " + str(GetSpriteHit( GetSpriteX( sprite[2] ), GetSpriteY( Sprite[2] ))))
Only registers a HIT with sprite[0]
... and this:
print( "Collision: " + str(GetSpriteCollision( sprite[2], Sprite[1] )))
print( "Hit : " + str(GetSpriteHit( GetSpriteX( sprite[2] ), GetSpriteY( Sprite[2] ))))
only registers a HIT with sprite[1]
AGK V2 user - Tier 1 (mostly)