Shrink or grow all the sprites in a group keeping the height to width ratio the same.
For example, a value of 2 will be make the sprite twice as big and a value of 0.5 will make the sprite half as big. Scaling up may make images blurry. The scale should always be a positive number.
The default scale is 1.
var group = createGroup(); group.add(createSprite(100, 200)); group.add(createSprite(300, 200)); function draw() { background("white"); drawSprites(); if (keyDown("right")){ group.setScaleEach(1.5); } if (keyDown("left")){ group.setScaleEach(0.1); } }
group.setScaleEach(scale)
Name | Type | Required? | Description |
---|---|---|---|
scale | Number | The positive scale to apply to all the sprites in the group. |
No return value. Changes output in the display after drawSprites() is called.
drawSprites()
is called.setColliderEach()
is called for group before it is scaled, the collider is not scaled. But if a group of sprites is first scaled and then the collider set, the scale is also applied to the collider.Found a bug in the documentation? Let us know at documentation@code.org