owner
是 StateMachine
类的一个属性,用于指定当前状态机的拥有者。拥有者可以是任何类型的对象,包括但不限于 DOM 元素、组件、控制器、视图等。
stateMachine.owner = owner;
owner
:任何类型的对象,用于指定当前状态机的拥有者。import { StateMachine } from 'yuka';
class Controller {
constructor() {
this.stateMachine = new StateMachine();
this.stateMachine.owner = this;
}
}
在上面的例子中,我们创建了一个名为 Controller
的 JavaScript 类,并将其实例作为状态机的拥有者。通过这种方式,我们可以在任何时间访问拥有者对象,并在状态机中执行一些逻辑。