Fuze Arena Logo
  • Forum
  • Creations
    Catalogue Showcase
  • Help

detectMapCollision()

Purpose

Used to detect whether a given sprite has collided with map collision boxes

Description

Receives a sprite handle and returns either true (collided) or false (not collided) if the sprite has collided with a map collision box data.

Syntax

collide = detectMapCollision( sprite )

Arguments

collide Returned Boolean value to indicate collision. Returns true (1) if collided, false (0) if not collided.

sprite Handle of the sprite being checked.

Example

// To view this map demo, please load the project "Map Collision" from FUZE Programs.
// Maps must be stored in the project you wish to load them into.

loadMap( "map1" )
img = loadImage( "Untied Games/Bat and Ball ball" )

plr = [
    .spr = createSprite(),
    .vel = {},
    .col = white
]

setSpriteImage( plr.spr, img )
setSpriteScale( plr.spr, { 1, 1 } )
setSpriteCamera( 0, 0, 2 )

loop
    centreSpriteCamera( 0, 0 )
    clear()
    updateSprites()

    c = controls( 0 )

    plr.vel += { c.lx, -c.ly } * 80
    plr.vel *= 0.87

    setSpriteSpeed( plr.spr, plr.vel )
    setSpriteColour( plr.spr, plr.col )

    drawMapLayer( 0 )
    drawMapLayer( 1 )

    if detectMapCollision( plr.spr ) then
        plr.col = red
    else
        plr.col = white
    endif

    drawSprites()

    printAt( 0, 0, "Move the ball by using the left control stick" )
    printAt( 0, 2, "Ball will appear red when colliding with map collision boxes, white when not colliding" )

    update()
repeat

Associated Commands

logo

©2019 FUZE Technologies Ltd. FUZE is a registered trademark of FUZE Technologies Ltd. All rights reserved.

Useful links

  • Fuze Main Site
  • Fuze Arena on Twitter
  • Fuze Arena on Youtube
  • Download Buyer

Contact Information

  • FUZE Technologies Ltd
    15 Clearfields Farm
    Wotton Underwood
    Aylesbury, Buckinghamshire
    ​England, HP18 0RS

  • +44 (0) 1844 239 432

  • contact@fuze.co.uk

© Copyright FUZE Technologies Ltd. All rights reserved.