Could someone explain how this works?
- local levelIndex =0
2. for i=0,2 do
3. for j=1,5 do
4. tablePlace = i*5 + j
5. levelIndex = levelIndex + 1
Could someone explain how this works?
2. for i=0,2 do
3. for j=1,5 do
4. tablePlace = i*5 + j
5. levelIndex = levelIndex + 1
Paste code once again
here is the code=
local levelIndex =0
for i=0,2 do
for j=1,5 do
tablePlace = i*5 + j
levelIndex = levelIndex + 1
I wrote to past code because it’s incomplete (ends missing)
Okay:
local levelIndex =0
for i=0,2 do
for j=1,5 do
tablePlace = i*5 + j
levelIndex = levelIndex + 1
local imagesId = levels[levelIndex]
levelImg = display.newImageRect (images[imagesId].getFile , 40, 40 )
levelImg.x = -30 + (j*65)
levelImg.y = 25 + (i*65)
group:insert(levelImg)
leveltxt = display.newText(tostring(tablePlace), 0,0, “TEN O CLOCK”, 25 )
leveltxt.x = -30 + (j*65)
leveltxt .y = 25 + (i*65)
leveltxt:setTextColor (250, 255, 251)
group:insert (leveltxt)
levelImg.destination = “level0”…tostring(tablePlace)
if images[imagesId].types ~= “locked” then
levelImg:addEventListener(“tap”, buttonHit)
end
Sorry but still code is incomplete
Okay well this is the only code that I could pull of this tutors website. It shows a menu with 15 levels 3 down 5 across. I want to increase the number of levels down and across using the for loop.
So if you pulled it from tutorial website then there should be explainded I hope.
Change the
for i = 0, 2 do
line to :
for i = 0, 4 do
if you want 5 total rows. But if you’re going to copy code from the tutorial into your own project, you have to make sure to get the rest of the code.
Paste code once again
here is the code=
local levelIndex =0
for i=0,2 do
for j=1,5 do
tablePlace = i*5 + j
levelIndex = levelIndex + 1
I wrote to past code because it’s incomplete (ends missing)
Okay:
local levelIndex =0
for i=0,2 do
for j=1,5 do
tablePlace = i*5 + j
levelIndex = levelIndex + 1
local imagesId = levels[levelIndex]
levelImg = display.newImageRect (images[imagesId].getFile , 40, 40 )
levelImg.x = -30 + (j*65)
levelImg.y = 25 + (i*65)
group:insert(levelImg)
leveltxt = display.newText(tostring(tablePlace), 0,0, “TEN O CLOCK”, 25 )
leveltxt.x = -30 + (j*65)
leveltxt .y = 25 + (i*65)
leveltxt:setTextColor (250, 255, 251)
group:insert (leveltxt)
levelImg.destination = “level0”…tostring(tablePlace)
if images[imagesId].types ~= “locked” then
levelImg:addEventListener(“tap”, buttonHit)
end
Sorry but still code is incomplete
Okay well this is the only code that I could pull of this tutors website. It shows a menu with 15 levels 3 down 5 across. I want to increase the number of levels down and across using the for loop.
So if you pulled it from tutorial website then there should be explainded I hope.
Change the
for i = 0, 2 do
line to :
for i = 0, 4 do
if you want 5 total rows. But if you’re going to copy code from the tutorial into your own project, you have to make sure to get the rest of the code.