Closed wooseok123 closed 1 month ago
If this change seems reasonable, I'll go ahead and make the necessary modifications and submit a commit
👍
👍
Hello thank you for considering my PR.
But i think we need to modify scenePlugin.js
as well.
All i modified is just sceneManager.js
// scenePlugin.js AS-IS
switch: function (key)
{
if (key !== this.key)
{
// need extra argument for data
this.manager.queueOp('switch', this.key, key);
}
return this;
},
// scenePlugin.js
// need extra argument for data
queueOp: function (op, keyA, keyB)
{
this._queue.push({ op: op, keyA: keyA, keyB: keyB });
return this;
},
feat : add data parameter to Scene.switch
Thank you for creating an amazing framework. While developing with it, I've noticed a few areas that I think could benefit from some changes, and I'd like to make a suggestion.
Problem
When using the
switch
method in Phaser to change scenes, we use the start method if the scene is being loaded for the first time.And the start method allows us to pass data as a second parameter. However, the current implementation of the switch method only accepts a key, making it impossible to pass data.
This limitation forces us to use the following pattern:
Solution
Thus, I would like to propose adding a data parameter to the switch method.
However, this change would require modifications to the ScenePlugin pattern since a queueOp function in the scene currently has a maximum of three parameters.
The switch method already uses these for the event name, the current scene, and the scene to be started, leaving no room for passing data.
But the queueOp function's parameters are currently labeled keyA, keyB, etc., and in cases where only one key is needed, the third parameter is used to pass data. This could potentially confuse developers who want to contribute to the Phaser and use Phaser. ex) stop Method
Therefore, I propose adding a fourth parameter to optionally receive data.
In cases where only one key is needed, we could pass null as the third parameter and use the fourth parameter for data, similar to the bringToTop method.