Hi, I need to set a variable number that can be changed…
// what would this.speed be?? only this specific
// one works below
this.speed = ?
app.on('game:getready', function () {
this.speed = 10;
}, this);
app.on('game:playing', function () {
this.speed = 18;
}, this);
Hi @_Lio3LivioN, could explain a bit more on what you are trying to achieve?
A variable or a property, as this.speed is in your example, in JavaScript can be set to be equal to any number. That number can be set in the start of your app and stay the same, or change as a response to input or other events, or even change on each game.
when I set an initial value, such as 10, that works perfectly. However, I want to speed this up once the playing stage has started to 18, and it does not change
No, @FBplus, you don’t need to do that, because this is passed as the third parameter of the on function, so the value of this will be correct inside the event handler functions.