My buttonTapped Function is working fine but my buttonTapped1 function isn’t working at all…
my button is usually connected to a table thats they have sceneName that is equal to the directory. but this error always pops up… addition button is fine in my UI but every time i click Subtraction it has an error.
operationMenu.lua local touchEnabled = false local buttonTapped local buttonTapped1 buttonTapped = function(event) local t = event.target local category = t.category if category ~= nil and touchEnabled == true then utils.playSound("select") composer.gotoScene(operations[category].sceneName1, {effect="slideLeft", time=300, params={category=category}}) end return true end buttonTapped1 = function(event) local t = event.target local category = t.category if category ~= nil and touchEnabled == true then utils.playSound("select") composer.gotoScene(operations[category].sceneName2, {effect="slideLeft", time=300, params={category=category}}) end return true end for i=1, #operations do local colour = operations[i].colour local y = (i-0.5)\*(categoryHeight+categoryOffset) + (categoryHeight/1) local textX = 36 local textW = \_W-(textX\*2) - 64 -- an extra 64 for icons local rect = display.newRect(\_W\*0.5, y, \_W, categoryHeight ) rect:setFillColor(colour[6], colour[3], colour[2]) rect.category = i rect:addEventListener("tap", buttonTapped) rect:addEventListener("tap", buttonTapped1) uiGroup:insert(rect) local arrow = display.newSprite(utils.uiSheet, {frames={utils.uiSheetInfo:getFrameIndex("arrow")}}) arrow.x = arrow.width/2 + 4 arrow.y = rect.y uiGroup:insert(arrow) local mainFont = "gomarice\_kaiju\_monster\_0.ttf" local title = display.newText({text=operations[i].title, x=textX, y=rect.y-6, width=textW, height=0, font=mainFont, fontSize=100}) title.anchorX = 0 title:setFillColor(1) uiGroup:insert(title) if operations[i].icon and operations[i].icon ~= "" then local icon = display.newSprite(utils.uiSheet, {frames={utils.uiSheetInfo:getFrameIndex(operations[i].icon)}}) icon.x = \_W - 40 icon.y = rect.y uiGroup:insert(icon) end end end
local M = { { title = "Addition", colour = {245/255, 147/255, 49/255}, sceneName1 = "scenes.difficultyMenuAddition", }, { title = "Subtraction", colour = {240/255, 101/255, 47/255}, sceneName2 = "scenes.difficultyMenuSubtraction", }, } return M