I am trying to understand the order the MV is calling it's functions and there is this weird thing.
As far as I understand .update() is a Javascript function that will be called automatically if it exists.
But there is the Input.update that is called by functions in SceneManager.update(). Shouldn't it be called twice? Once through SceneManager and once through itself?
The whole Input-Class looks the same like the SceneManager class so Update should work there too ... Why is that?
Is it a Javascript-thing that it is smart enough to only make one call when multiple Updates call the function?
Code-Example from the rpg_managers.js and rpg_core.js:
As far as I understand .update() is a Javascript function that will be called automatically if it exists.
But there is the Input.update that is called by functions in SceneManager.update(). Shouldn't it be called twice? Once through SceneManager and once through itself?
The whole Input-Class looks the same like the SceneManager class so Update should work there too ... Why is that?
Is it a Javascript-thing that it is smart enough to only make one call when multiple Updates call the function?
Code-Example from the rpg_managers.js and rpg_core.js:
Code:
SceneManager.update = function() { //HERE!! console.log("SceneManager.update"); try { this.tickStart(); this.updateInputData(); this.updateMain(); this.tickEnd(); } catch (e) { this.catchException(e); }};//Calls:SceneManager.updateInputData = function() { //console.log("SceneManager.updateInputData"); Input.update(); TouchInput.update();};//Calls:Input.update = function() { //HERE! //console.log("Input.update"); this._pollGamepads(); if (this._currentState[this._latestButton]) { this._pressedTime++; } else { this._latestButton = null; } for (var name in this._currentState) { if (this._currentState[name] && !this._previousState[name]) { this._latestButton = name; this._pressedTime = 0; this._date = Date.now(); } this._previousState[name] = this._currentState[name]; } this._updateDirection();};