collideSprites()
Purpose
Collides two sprites
Description
Syntax
c = collideSprites( spriteA, spriteB, resolve1, resolve2 )
Arguments
spriteA handle of first sprite
spriteB handle of second sprite
resolve1 if true the first sprite can be moved by the collision
resolve2 if true the second sprite can be moved by the collision
c.exists true if collision occurred
c.a first sprite in the collision
c.b second sprite in the collision
*c.resolution_vector representing how sprite A was pushed during the collision
*c.resolution_vector representing how sprite B was pushed during the collision
Example
image = loadImage( "Untied Games/Enemy small top C", false )
ship = []
for i = 0 to 2 loop
ship[i] = createSprite( image )
setSpriteImage( ship[i], image )
setSpriteScale( ship[i], { 5, 5 } )
setSpriteCollisionShape( ship[i], SHAPE_TRIANGLE, 25, 25, 180 )
ship[i].show_collision_shape = true
repeat
setSpriteRotation( ship[0], 270 )
setSpriteSpeed( ship[0], { 240, 0 } )
setSpriteSpeed( ship[1], { 0, 120 } )
setSpriteColour( ship[1], { 0, 0, 1, 1 } )
setSpriteLocation( ship[0], { 0, gHeight() / 2 } )
setSpriteLocation( ship[1], { gWidth() / 2, 0 } )
while ship[0].x < gWidth() loop
clear()
updateSprites()
collideSprites( ship[0], ship[1] )
drawSprites()
update()
repeat
Associated Commands