defineBehavior
此内容尚不支持你的语言。
defineBehavior<
S>(name,def):ComponentDef<S>
Defined in: behavior.ts:94
Define a per-entity behavior. Returns the backing ComponentDef (so you can spawn/insert it from code), and registers the lifecycle system as a side effect.
Type Parameters
Section titled “Type Parameters”S extends object
Parameters
Section titled “Parameters”string
BehaviorDef<S>
Returns
Section titled “Returns”ComponentDef<S>
Example
Section titled “Example”export const Patrol = defineBehavior('Patrol', { state: { speed: 60 }, update(ctx, dt) { ctx.get(Transform).position.x += ctx.self.speed * dt; },});