When to use this.data.set()?

function create(){
this.GameOver = false;
this.data.set(‘GameOver’, false);
}

I am wondering when to assign data to “this.data” rather than assign it to “this” directly.
Can someone tell me the concept? Many Thanks.

If you just need “a variable to use in this scene”, use this.GameOver.

this.data is a more structured interface.

Thanks for your reply. The data manager state that:

“The parent must either extend EventEmitter, or have a property called events that is an instance of it”

Does it mean when the data change, the data change event could be emitted?

Is it better to trigger a “data” event rather than put GameOver variable to update()

Yes, the scene’s data manager (this.data) triggers events from the scene’s event emitter (this.events).

You can use scene events without the scene data manager. For example, you would just emit a gameover event, no data involved:

this.events.on('gameover', function () {/*…*/});
// …
this.events.emit('gameover');

Thanks, this can be a solution to my question already.