setSpriteCollisionShape()
Purpose
Sets the sprite's collision shape
Description
Sets the sprite's collision shape to the given shape The collision shape will rotate, scale, and move along with the sprite. The size will be automatically set according to the sprite's image or tile dimensions
Syntax
setSpriteCollisionShape( sprite, shape )
setSpriteCollisionShape( sprite, shape, width, height, rotation )
Arguments
sprite handle of the sprite
shape shape of the sprite's collision (SHAPE_BOX, SHAPE_TRIANGLE, or SHAPE_CIRCLE)
width width of the shape in pixels
height height of the shape in pixels
rotation rotation of the shape in default units
Example
image = loadImage( "Untied Games/Enemy small top C", false )
ship = []
for i = 0 to 2 loop
ship[i] = createSprite()
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 } )
collide = false
while !collide loop
clear()
updateSprites()
drawSprites()
update()
collide = detectSpriteCollision( ship[0],ship[1] )
repeat
Associated Commands