Hello everyone,
I am trying to increase the score by one each second. However, it just increments once, and doesn’t change after that. At the lose event, the score is supposed to be alerted. The problem is shown in the recording below.
My code is as follows.
CollideOff.prototype.initialize = function() {
this.score = 0;
this.timer = 0;
this.entity.collision.on('collisionstart', this.onCollisionStart, this);
};
// update code called every frame
CollideOff.prototype.update = function(dt) {
this.timer += dt;
if (this.timer >= 1) {
this.score ++;
this.timer =0;
}
};
This is for incrementing.
if (result.other.name === "SpinningBallLeft") {
this.entity.enabled = false;
if (this.ObjectType === 'death') {
this.app.root.findByName('part_burst3').particlesystem.reset();
this.app.root.findByName('part_burst3').particlesystem.play();
this.app.fire("camera:shake");
setTimeout(function (){this.app.root.findByName("Game_Over").enabled = true;}.bind(this), 1000);
alert(this.score);
}
This is for alerting. Note - full code is not given above, so pardon missing brackets.
EDITOR - https://playcanvas.com/editor/scene/874865
How can I continue?