body(opt?: BodyCompOpt): BodyComp
Physical body that responds to gravity. Requires "area" and "pos" comp. This also makes the object "solid".
param
opt- Options for the body component. See
// bean jumpy const bean = add([ sprite("bean"), // body() requires "pos" and "area" component pos(), area(), body(), ]) // when bean is grounded, press space to jump // check out #BodyComp for more methods onKeyPress("space", () => { if (bean.isGrounded()) { bean.jump() } }) // run something when bean falls and hits a ground bean.onGround(() => { debug.log("oh no!") })
returns
The body comp.
since
v2000.0