In my code:
When the spacebar is pressed an enemy object is created, a corresponding enemyBox is created as well. But the enemyBox.speedMultiplier instance variable isn't getting set to the enemies.speedMutliplier value and instead is set to the default value (1). It's almost as if the enemies.speedMutliplier value hasn't been completely set in the spawnEnemy function before the 'on created' block is called.
Can someone please explain why this is happening? Maybe it's a synchronization issue? I admit I don't understand sync / async very well.
https://drive.google.com/file/d/1hOtJEhgl5agAFPPgpA222me8YH86wrU0/view?usp=sharing
Develop games in your browser. Powerful, performant & highly capable.
Yes it's what you thought because it's all happening in the same tick. There is a quick fix if you add Wait 0 seconds to the top of the 'on created' actions it will wait for the function to finish.