Making tables

When the game is over i am trying to show a scorecard. It will be based off of 10 points of criteria. What would be the best way to approach this?
I would have like 10 columns and about 2 rows.

A very inefficient way that i was thinking is to make it using a picture as a background and filling each and every box.

I am trying to learn about tables now, but i haven't seen how to actually print a table on the screen.
Could someone give me an example on how to do this?

best way to show this kind of things is to learn how "json" library works in corona, its pretty awesome thing

and for displaying a table values, there's plenty of ways to do this, easiest is just a display.newText function

something like this:

1
2
3
4
5
6
7
8
9
10
11
12
13
local t = {
1,2,
3,4,
5,6
}
 
 
for i=#t,1,-2 do
for l = 1,#t,2 do 
local txt = display.newText(t[l], 0, 0+(l-1)*50,nil,50)
local txt = display.newText(t[i], 100, 0 +(i-1)*50,nil,50)
end
end

can you explain what this says, or means?

1
2
        for i=#t,1,-2 do
        for l = 1,#t,2 do 

its a for loop, its kinda hard to explain, so check lua documentation)

One last question... i am trying to explore the json library.

1
2
3
4
5
6
        local t = {}
        
        t[1] = 320
        t[2] = 192
        t[3] = 100
        

i think i got it!

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
 
        local t = {}
        
        t[1] = 1
        t[2] = 3
        t[3] = 5
        
        
        for l = 1,#t,1 do 
        
        local txt = display.newText(l, 250, 0+(l-1)*25,nil,25)
        txt.rotation = 90
        txt.xScale = .5
        txt.yScale = .5
 
        local txt = display.newText(t[l], 200, 0+(l-1)*25,nil,25)
        txt.rotation = 90
        txt.xScale = .5
        txt.yScale = .5
 
        end

or you can do this like that:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
        local t = {}
        
        t[1] = 1
        t[2] = 3
        t[3] = 5
        
        
        for l = 1,#t,1 do 
        
        local txt = display.newText(l .."   ".. t[l], 0, 0+(l-1)*25,nil,50)
        txt.xScale = .5
        txt.yScale = .5
                
        end

Ahh very good! Thanks!

views:1585 update:2012/1/4 9:12:54
corona forums © 2003-2011