天天看点

phaser3笔记:setBounce、setVelocity

示例的里的代码,使用的物理引擎是

arcade

,里面涉及运动碰撞弹跳的,会有两个方法,

setBounce

setVelocity

, 这两个方法字面意义都挺清晰的,我理解起来,花了一点时间,这里记录一下。

设置弹跳

setBounce

官方文档是是这么描述的

setBounce(x [, y])

Sets the bounce values of this body.

Bounce is the amount of restitution, or elasticity, the body has when it collides with another object. A value of 1 means that it will retain its full velocity after the rebound. A value of 0 means it will not rebound at all.

我的理解是,这是设置反弹起来后的速度保持。

例如,setBounce(1) , 原来在Y轴的速度是100,那么碰撞后,反弹的速度也是100。

设置速度

setVelocity

官方文档是这样说明的:

setVelocity(x [, y])

Sets both the horizontal and vertical velocity of the physics body

这是设置物体横向(x轴)和纵向(y轴)的速度。值的绝对值越大,速度越快。

目前没有看到这个值和时间的关系。