hexonaut / haxe-phaser

Haxe externs for Phaser.
MIT License
51 stars 9 forks source link

Non optional parameter named "parameter" after optional parameters in StateManager #29

Closed NickHolder closed 10 years ago

NickHolder commented 10 years ago

There's a non optional parameter named "parameter" after optional parameters in phaser.core.StateManager

in start()

/**
* Start the given State. If a State is already running then State.shutDown will be called (if it exists) before switching to the new State.
*/
function start (key:String, ?clearWorld:Bool = true, ?clearCache:Bool = false, parameter:Dynamic):Void;

and also restart()

/**
     * Restarts the current State. State.shutDown will be called (if it exists) before the State is restarted.
     */
    function restart (?clearWorld:Bool = true, ?clearCache:Bool = false, parameter:Dynamic):Void;
hexonaut commented 10 years ago

This looks like a bug in js2hx as optional parameters should never come after non-optional ones. I'll get this fixed shortly.

RafaelOliveira commented 10 years ago

Phaser Source code has parameter in the docs, but not in the method call:

/**
    * Start the given State. If a State is already running then State.shutDown will be called (if it exists) before switching to the new State.
    *
    * @method Phaser.StateManager#start
    * @param {string} key - The key of the state you want to start.
    * @param {boolean} [clearWorld=true] - Clear everything in the world? This clears the World display list fully (but not the Stage, so if you've added your own objects to the Stage they will need managing directly)
    * @param {boolean} [clearCache=false] - Clear the Game.Cache? This purges out all loaded assets. The default is false and you must have clearWorld=true if you want to clearCache as well.
    * @param {...*} parameter - Additional parameters that will be passed to the State.init function (if it has one).
    */
    start: function (key, clearWorld, clearCache) {
hexonaut commented 10 years ago

It's using variable length arguments. The function will read the special keyword "arguments" and load the arguments in that way.