I have a function that whenever I pass a string into, it turns into a table and I don't know why. Any help is very appreciated. Here's my code:
function gotoSkip(para)
print(para)
print(type(para))
--scene:removeEventListener( "create", scene )
--composer.gotoScene(para)
end
function scene:create( event )
local sceneGroup = self.view
background = display.newImageRect(sceneGroup,"images/white.jpg",768,1500)
background.x = display.contentCenterX
background.y = display.contentCenterY
local skipButton = display.newText(sceneGroup, "Skip", 600, 1300, nativeSystemFont, 60)
skipButton:setFillColor(0,0,256)
skipButton:addEventListener("tap",gotoSkip, "StringExample")
end
Here is the result of the two print statements respectively:
table: 0D27FB88 (or some other memory address)
table
addEventListenerfunction only gets 2 arguments, so you should remove that third argument.If you wanna pass parameter to a function from an Event Listener, there are 2 ways;
1-) You can set a property for event.target;
2-) You can use a sub function;
You can remove its listener like this;
Also
nativeSystemFontisn't a valid constant unless you defined it. Correct one isnative.systemFont.