The velocity lost or gained by a sprite during a collision or bounce.
For example: A value of 1 is perfectly elastic, no velocity is lost. A value of 0 is perfectly inelastic, no bouncing. A value between 0 and 1 is inelastic, this is the most common in nature. A value greater than 1 is hyper-elastic, velocity is increased like in a pinball bumper
The default bounciness is 1. All sprite properties can be both accessed and updated.
Demonstrate three different bounciness levels.
// Demonstrate three different bounciness levels. var sprite1 = createSprite(75, 200); var sprite2 = createSprite(200, 200); var sprite3 = createSprite(325, 200); var wall=createSprite(200, 400, 400, 20); sprite1.velocityY=2; sprite2.velocityY=2; sprite3.velocityY=2; sprite1.bounciness=0.5; sprite2.bounciness=1; sprite3.bounciness=2; function draw() { background("white"); drawSprites(); sprite1.bounceOff(wall); sprite2.bounceOff(wall); sprite3.bounceOff(wall); }
sprite.bounciness
The bounciness of the sprite.
drawSprites()
is called.Found a bug in the documentation? Let us know at documentation@code.org