Why it says required?

Sory for bad english

display.newText( [parentGroup,] string, left, top, font, size )

display.newText( [parentGroup,] string, left, top, [width, height,] font, size )

In the corona’s api docs says that font and size in the text function are required, but i can throw them out when declare,why?

how this parametres are working? Are the arguments must be at right position of a list? or i can don’t remember their positions?

Thank you) english is my native language)

Hi Sakendev.

What is the problem that you are facing?

Lua can have optional parameters in the middle of the parameter list because the function checks for the type of objects being passed in.  So if the 4th parameter is a number, then it knows you’re passing in a width and height.  If it sees a string there like “Helvetica” or native.systemFont, then it knows you did not pass a width, height in and then processes it as a string, number for the font and size.

Thanks to all

Hi Sakendev.

What is the problem that you are facing?

Lua can have optional parameters in the middle of the parameter list because the function checks for the type of objects being passed in.  So if the 4th parameter is a number, then it knows you’re passing in a width and height.  If it sees a string there like “Helvetica” or native.systemFont, then it knows you did not pass a width, height in and then processes it as a string, number for the font and size.

Thanks to all