Hi there!
I'm making a plugin, and I don't want to put a lot of if conditions... so I'm trying to learn function parameters.
After a hard time trying to figure that out, I came here asking for help... ^^'''
here is the code:
The idea is to make in a way that I only have to replace the two parameters to get what I want.
Then I call the function. But this is what I get...
I manage it to work like that:
I'm making a plugin, and I don't want to put a lot of if conditions... so I'm trying to learn function parameters.
After a hard time trying to figure that out, I came here asking for help... ^^'''
here is the code:
Code:
function elipic (id, property) {
var casa = property;
return SceneManager._scene._spriteset._pictureContainer.children[id - 1].casa;
};
The idea is to make in a way that I only have to replace the two parameters to get what I want.
Then I call the function. But this is what I get...
I manage it to work like that:
Code:
var casa;
function elipic (id) {
if(casa == "width") {
return SceneManager._scene._spriteset._pictureContainer.children[id - 1].width;
} else if (casa == "height") {
return SceneManager._scene._spriteset._pictureContainer.children[id - 1].height;
}
};