Nested Groups Anyone?

Hi everyone, OK, this one is a bit of a challenge…

I’m using Corona’s UI template (Corona SDK/SampleCode/Interface/WidgetDemo), which uses storyboard to move between different  (not separate LUA files) scenes, ie;

<code>

function newScene:createScene( event )
    local group = self.view

</code>

Obviously I wanted to a little customising, so within one of ‘those’ scenes, I imported the ‘draw a line’ code (excellent script for drawing on the stage http://sree.cc/corona-sdk/easy-finger-drawing-in-corona )

The lines that are drawn are assigned to new display groups, like this:

<code>

local lineTable = {}   
    local newLine = function(event)
    
    local function drawLine()
    local line = display.newLine(linePoints[#linePoints-1].x,linePoints[#linePoints-1].y,linePoints[#linePoints].x,linePoints[#linePoints].y)
    line:setColor(lineColor.R, lineColor.G, lineColor.B);
    line.width=lineWidth;
    
    lineTable[i]:insert(line)

</code>

The problem is getting this function within my main display group, I just can’t get it to work… Is there anyway to ‘nest’ lineTable[i]:insert(line) within my local group?, so it responds with the rest of the scene?

Thanks very much if you can help.

Mark

By the way, why can’t I get my code hi-lighted? Ive tried <lua> and <code> but it’s not happening.

I don’t understand why you’re using ‘lineTable’. what is that for? That is not how you add a line display object to a display group. You do it like this:

-- First, create the display group, in this case we'll use the same name as the storyboard scene group local group = self.view -- this would normally be created like this: display.newGroup() -- Option A: Assign directly in the line constructor local line = display.newLine( group, ax,ay, bx,by ) -- Option B: Assign after creating the line group:insert( line ) &nbsp;

Once this is done, the line will be part of the storyboard’s scene display group.

http://docs.coronalabs.com/daily/api/library/display/newLine.html

http://docs.coronalabs.com/daily/api/library/storyboard/index.html#scenetemplate.lua

As for marking code as code in the forum poster, highlight it in the rich text box and click the blue <> button, between the image insert button and the break link button.

By the way, why can’t I get my code hi-lighted? Ive tried <lua> and <code> but it’s not happening.

I don’t understand why you’re using ‘lineTable’. what is that for? That is not how you add a line display object to a display group. You do it like this:

-- First, create the display group, in this case we'll use the same name as the storyboard scene group local group = self.view -- this would normally be created like this: display.newGroup() -- Option A: Assign directly in the line constructor local line = display.newLine( group, ax,ay, bx,by ) -- Option B: Assign after creating the line group:insert( line ) &nbsp;

Once this is done, the line will be part of the storyboard’s scene display group.

http://docs.coronalabs.com/daily/api/library/display/newLine.html

http://docs.coronalabs.com/daily/api/library/storyboard/index.html#scenetemplate.lua

As for marking code as code in the forum poster, highlight it in the rich text box and click the blue <> button, between the image insert button and the break link button.