I see people using these, and I am aware of their existence, but I still just discard them when I make functions. Can anyone give me an example of what kind of use they might have?
For sure! So function parameter is basically a special kind of variable that can only be used inside that function block (kind of like the draggable “sprite” or “otherSprite” variables in a sprite overlaps block). Functions are often used to avoid repeating code, so if you were changing the level of your game you might have a
startLevel function, like:
The function needs to know the current level and what tile to put the player on. You can set those to be variables (which are “global”, meaning they can be used anywhere in your program), like above, or you can pass them in as parameters, which are “local” (can only be used in the function), like this:
They can be extremely useful if you want to run the same code multiple times with a few small changes–if you were making a Pokemon-style game, for example, and wanted to create some animals with different names and stats, you could do something like this:
Hope that helps!
Thanks, that does make sense!