group.minDepth()
Category:Groups
Returns the lowest depth in a group.
Sprites are drawn, when drawSprites()
is executed, in order from lowest depth to highest depth. The sprites drawn later will overlay sprites drawn earlier.
Examples
var group = createGroup();
for (var i = 0; i < randomNumber(10, 20); i++) {
group.add(createSprite(randomNumber(0, 400), randomNumber(0, 400),randomNumber(10, 20),randomNumber(10, 20)));
}
console.log(group.minDepth());
console.log(group.maxDepth());
fill("red");
function draw() {
background("white");
drawSprites();
for (var i = 0; i < group.maxDepth(); i++) {
var temp=group.get(i);
text(i, temp.x, temp.y);
}
}
Syntax
group.minDepth()
Returns
The lowest depth in the group.
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 support@code.org.