detectSprites(layer,area) , method of scene

Return an array of Sprites (identifiers) which are completely inside a given area.

name type description
layer int layer of the world (must be >= 0)
area object Rectangle or Circle, see below for its properties
name type description
type string Rectangle
left num left x-coordinate of the rectangle left
top num top y-coordinate of the rectangle top
right num right x-coordinate of the rectangle right
bottom num bottom y-coordinate of the rectangle bottom
name type description
type string Circle
x num center x coordinate
y num center y coordinate
radius int
// Rectangular area
var spritesInRectangle = UB.scene.detectSprites(0,{
type: "Rectangle",
left: 0,
top: 0,
right: 1000,
bottom: 1000,

// Circular area
var spritesInCircle = UB.scene.detectSprites(0,{
type: "Circle",
x: 500,
y: 500,
radius: 300

// or using object properties
var area = {"type":"Circle"}
area.x = 500
area.y = 500
area.radius = 300
var spritesInCircle = UB.scene.detectSprites(0,area);

See all methods of the api.