group.setHeightEach()
Category:Groups
Sets the height of the sprite placeholder rectangle for every sprite in the group.
The default height is 100.
Examples
var group = createGroup();
group.add(createSprite(100, 200));
group.add(createSprite(300, 200));
function draw() {
background("white");
drawSprites();
if (mouseDown("leftButton")){
group.setHeightEach(20);
}
if (mouseDown("rightButton")){
group.setHeightEach(100);
}
}
Syntax
group.setHeightEach(height)
Parameters
Name | Type | Required? | Description |
---|---|---|---|
height | Number | The height of the sprites in pixels. |
Returns
No return value. Changes output in the display after drawSprites() is called.
Tips
- use
group.setScaleEach
to resize a sprite and keep the height to width ratio constant. - 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.
- Any changes to the properties of a sprite will not be seen until after
drawSprites()
is called.
Found a bug in the documentation? Let us know at support@code.org.