Sets the width of the sprite placeholder rectangle for every sprite in the group.
The default width is 100.
var group = createGroup(); group.add(createSprite(100, 200)); group.add(createSprite(300, 200)); function draw() { background("white"); drawSprites(); if (mouseDown("leftButton")){ group.setWidthEach(20); } if (mouseDown("rightButton")){ group.setWidthEach(100); } }
group.setWidthEach(width)
Name | Type | Required? | Description |
---|---|---|---|
width | Number | The width of the sprites in pixels. |
No return value. Changes output in the display after drawSprites() is called.
group.setScaleEach
to resize a sprite and keep the height to width ratio constant.drawSprites()
is called.Found a bug in the documentation? Let us know at documentation@code.org