[英]How to reset to initial state when using A-Frame `state` component?
If I follow instructions here and I have a game that changes the state over time, how do I reset the state? 如果我按照此处的说明进行操作,并且我有一个会随着时间改变状态的游戏,该如何重置状态?
Here's my attempt at pseudo code that does not work: 这是我对不起作用的伪代码的尝试:
AFRAME.scenes[0].systems.state.state.game = AFRAME.scenes[0].systems.state.initialState.game;
Or perhaps it is not possible to fetch initial settings from the component, and instead I should create a global constant in my project like initialStateMine
that is used by the state component for initialization and also another function to reset the state? 或者,也许无法从组件中获取初始设置,而是应该在项目中创建一个全局常量(如initialStateMine
,该常量由状态组件用于初始化以及另一个用于重置状态的函数?
Yeah, keep an initial state in a variable. 是的,将初始状态保留在变量中。 Then if you want to replace Object.assign(state, initialState)
; 然后,如果要替换Object.assign(state, initialState)
;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.