Checks if any sprite in the group is touching the target sprite or any sprite in the target group.
All sprites have a collider area that defines the active area to detect collisions with other sprites and mouse interactions. Use setColliderEach() to change the default collider area, a rectangle, for a group of sprites.
var target = createSprite(200, 200);
target.shapeColor="green";
var group = createGroup();
for (var i = 0; i < 5; i++) {
group.add(createSprite(randomNumber(0, 400), randomNumber(0, 400), 20, 20));
}
function draw() {
background("white");
drawSprites();
if (group.isTouching(target)) {
target.shapeColor="red";
}
}
group.isTouching(target)
| Name | Type | Required? | Description |
|---|---|---|---|
| target | Sprite or Group | The name of the target sprite or target group you want to check for touching. |
Boolean true or false.
setColliderEach() to change the shape and size of the collider area and set debug to true for each sprites.Found a bug in the documentation? Let us know at documentation@code.org