Kieran F.
Kieran F.

Reputation: 555

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?

Upvotes: 0

Views: 207

Answers (1)

ngokevin
ngokevin

Reputation: 13233

Yeah, keep an initial state in a variable. Then if you want to replace Object.assign(state, initialState);

Upvotes: 1

Related Questions