I have a working program which has two sets of numbers 1-10 on the left and right side of the screen. If a player clicks on a number on the left side the program knows that you have only selected that number on the left side and displays it on the screen. If the player picks a number on the right side the program knows that the player has selected two numbers and to add those two numbers together. I was wondering how I can display some images on the bottom so that if a player picks a number they get to see a visual amount of that number. Like for instance if a player picks the number 5 the screen will display 5 images on the bottom of that number set. I had set up a table of postions for the images on the left side to see if I can get something working before I transfer over to the left side… Heres the code I got so far:)
[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 number1 = display.newImageRect(“numbers.png”,464,471)
number1.x = 250; number1.y = 243
local number2 = display.newImageRect(“numbers.png”,464,471)
number2.x = 750; number2.y = 253
local hitSpot = {}
local res, var1, var2 = 0,0,0
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
local number2Text = display.newText(string.format(“Number: %02d”, 0), 0, 0, native.systemFontBold, 40)
number2Text:setTextColor( 255,0,0 )
number2Text.x = 500; number2Text.y = 470
local answer = display.newText(string.format(“Answer: %02d”, 0), 0, 0, native.systemFontBold, 40)
answer:setTextColor( 33,31,32)
answer.x = 500; answer.y = 540
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 t1 = {
{ 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 t2 = {
{ 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 }
}
local bt1 = {
{ x = 60, y = 530 },
{ x = 120, y = 530 },
{ x = 180, y = 530 },
{ x = 240, y = 530 },
{ x = 300, y = 530 },
{ x = 60, y = 650 },
{ x = 120, y = 650 },
{ x = 180, y = 650 },
{ x = 240, y = 650 },
{ x = 300, y = 650 },
}
local function numberSet1(e)
for i=1,#t1 do
hitNumber = 0
local outCome = hitTestObject(e, t1[i].x - 20, t1[i].y - 22, t1[i].x + 20, t1[i].y + 22)
if (outCome == true) then
hitNumber = i
break --used to stop looping through the other items
end
end
numberText.text = string.format(“Number: %02d”, hitNumber)
var1 = hitNumber
res = tonumber(var1) + tonumber(var2)
print("TOTAL " … res)
answer.text = string.format(“Answer: %02d”, res)
end
local function numberSet2(e)
for i=1,#t2 do
hit2Number = 0
local outCome = hitTestObject(e, t2[i].x - 20, t2[i].y - 22, t2[i].x + 20, t2[i].y + 22)
if (outCome == true) then
hit2Number = i
break --used to stop looping through the other items
end
end
number2Text.text = string.format(“Number: %02d”, hit2Number)
var2 = hit2Number
res = tonumber(var1) + tonumber(var2)
print("TOTAL " … res)
answer.text = string.format(“Answer: %02d”, res)
end
number1:addEventListener(“touch”,numberSet1)
number2:addEventListener(“touch”,numberSet2)[/lua]
Thanks for any suggestions
Jake [import]uid: 51459 topic_id: 16072 reply_id: 316072[/import]
[import]uid: 51459 topic_id: 16072 reply_id: 59766[/import]