What I have is one set of numbers 1-10 and another set of numbers 1-10… when I click on the left side of numbers the screen tells me what number it is… I want to incorporate the other set of numbers to do the same thing but I am having a little trouble… I also want to be able to add the two numbers that where selected and get an end result
[lua]display.setStatusBar( display.HiddenStatusBar ) – HIDE STATUS BAR
local screenW = display.contentWidth
local screenH = display.contentHeight
local BG = display.newImageRect(“background.png”, 1024, 768)
BG.x = screenW/2; BG.y = screenH/2
local numbers = display.newImageRect(“numbers.png”,464,471)
numbers.x = 250; numbers.y = 243
local numbers2 = display.newImageRect(“numbers.png”,464,471)
numbers2.x = 750; numbers2.y = 253
local hitSpot = {}
local numberText = display.newText(string.format(“Number: %02d”, 0), 0, 0, native.systemFontBold, 40)
numberText:setTextColor( 255,0,0 )
numberText.x = 500; numberText.y = 400
function hitTestObject(point, xMin, yMin, xMax, yMax)
local xInside = point.x >= xMin and point.x <= xMax
local yInside = point.y >= yMin and point.y <= yMax
return (xInside and yInside)
end
local hitPoints = {
{ x=310, y=178 },
{ x=340, y=220 },
{ x=340, y=270 },
{ x=305, y=312 },
{ x=258, y=328 },
{ x=203, y=315 },
{ x=165, y=280 },
{ x=165, y=228 },
{ x=185, y=181 },
{ x=249, y=160 }
}
–[[
local hitPoints = {
{ x=810, y=188 },
{ x=840, y=233 },
{ x=840, y=280 },
{ x=805, y=322 },
{ x=755, y=340 },
{ x=700, y=325 },
{ x=660, y=285 },
{ x=660, y=235 },
{ x=685, y=188 },
{ x=750, y=170 }
}
]]
for i=1,#hitPoints do
hitSpot = display.newImageRect(“hitSpot.png”, 44, 40)
hitSpot.x = hitPoints[i].x; hitSpot.y = hitPoints[i].y
hitSpot.alpha = .3
end
local x0 , y0, x1, x2
local function selectNumber(e)
if e.phase == “began” then
x0 = e.x
y0 = e.y
elseif e.phase == “ended” then
local hitNumber = 0
for i=1,#hitPoints do
local outcome = hitTestObject(e, hitPoints[i].x - 20, hitPoints[i].y - 22, hitPoints[i].x + 20, hitPoints[i].y + 22)
if (outcome = true) then
hitNumber = i
end
end
numberText.text = string.format(“Number: %02d”, hitNumber)
print(“hit” … hitNumber)
end
end
numbers:addEventListener(“touch”,selectNumber)[/lua] [import]uid: 51459 topic_id: 16043 reply_id: 316043[/import]
Which was make two tables work the same way!!