Getting Multiple Print data on terminal using Composer API.

Hi,

While creating the function i always use the print command to check my function is working correctly or not. Today i was creating some listeners to goto next scene and return back to the previous scene using Composer UI.

–this code will be in the firstpage.lua–

local skip = display.newImage (“skipbutton.png”)

function toskip (event)

if event.phase == “began” then

Print (skipped)

composer.gotoScene (“secondpage”)

end

end

skip:addEventListener (“touch” , toskip)

–this code will be in the secondpage.lua–

local back = display.newImage (“backbutton.png”)

function toback (event)

if event.phase == “began” then

Print (back)

composer.gotoScene (“firstpage”)

end

end

back:addEventListener (“touch” , toback)

While using the skip and back button to navigate to both the pages check out the terminal, it is showing lots of skipped and back printed on terminal.

Can any one please tell me why this happenning?

Looking forward for a reply.

its just because you’re using a touch event listener which are ridiculously sensitive, nothing to worry about.

Oh just a little tip to optimise your code, instead of putting event.phase == “began”, just remove that because string comparison in lua is taxing and your not using any other phases.

Regards, Lemon

Thanks Lemon, I appreciate your help. :slight_smile:

Regards

its just because you’re using a touch event listener which are ridiculously sensitive, nothing to worry about.

Oh just a little tip to optimise your code, instead of putting event.phase == “began”, just remove that because string comparison in lua is taxing and your not using any other phases.

Regards, Lemon

Thanks Lemon, I appreciate your help. :slight_smile:

Regards