Maybe this is related to javascript’s dynamically binding this
. You can simply assign self
to this
, and use self
instead of this
in the function.
var self = this;
this.entity
.tween(this.entity.getLocalPosition())
.to(new pc.Vec3(this.entity.getLocalPosition().x, this.entity.getLocalPosition().y, -0.007), 2.0, pc.SineOut)
.on('complete', function () {
self.inPosition = true;
self.moving = false;
self.app.fire("input:ready");
})
.start();
or use arrow function instead of normal function:
//...
.on('complete', () => {
this.inPosition = true;
this.moving = false;
this.app.fire("input:ready");
});