group.contains()

Category:Groups

Checks if the sprite is in the group.

Examples

// Is the sprite in the group (red) or not?
var group = createGroup();
var sprite1 = createSprite(200, 200);
if (randomNumber(0, 1)==1) group.add(sprite1);
if (group.contains(sprite1)) {
  group.setColorEach("red");  
}
function draw() {
  background("white");
  drawSprites();
}

Syntax

group.contains(sprite)

Parameters

Name Type Required? Description
sprite Sprite The sprite you want to find in the group.

Returns

Boolean true or false.

Tips

  • Groups of sprites all have the same functions and you use the dot notation (combining the name of the group, followed by a dot, with the function name) to call the function for that group of sprites.

Found a bug in the documentation? Let us know at documentation@code.org