[RESOLVED]Unable to update scores from within update() method

[RESOLVED]Unable to update scores from within update() method
0.0 0


I am trying to implement a tetris-like game where one object is falling down and it can fall into one out of three baskets. A life is lost if the object falls into the wrong basket.

I use the this.scheduleUpdate() function to simulate the fall of the object(Translate down by 0.6 basically) and to track when the object has fallen into the wrong basket in which event I immediately call this.scheduleOnce(this.score) The problem is that though only one life must be deducted on each call of this.score(), the deduction is erratic across different computers. On old machines, all lives are deducted at once, on some machines 2 lives are deducted at once and so on. Why’s this? How can I fix the problem?


i think the problem is that you didn’t remove the if check in your update once your object is in the wrong spot, and so, it schedules the score function multiple times?


Sorry for the late reply. I fixed this. I was basically calling a function from scheduleUpdate() that was again calling scheduleUpdate() without unscheduling the update() function(with unscheduleUpdate()) anywhere. Thank you!