display.newCircle doesn't always accept parent group (results in Runtime Error)

SOLVED: The problem turned out to be that the group was not nil, but the pointer pointed to a group that had already been removed. As a result, it was not a valid parent group and I was unaware of this until after further debugging. For example:

group = display.newGroup()

copyOfGroup = group

display.remove(copyOfGroup) --this will actually eliminate the original definition because the group object itself is not copied, but the pointer instead.

And therefore, group:insert(object) will fail as will any attempt to include it as a parent group for new objects.

=============

Hi,

The Corona syntax for display.newCircle is located at: https://docs.coronalabs.com/api/library/display/newCircle.html

The syntax is:

display.newCircle( [parent,] xCenter, yCenter, radius )

In the daily build 3350, the parent group is not always accepted and I receive the message that a number is expected and not a table.

For the longest time I have been using “group:insert(object)” to manage my groups, but in my newest App that it is Beta, I am always assigning the parent group when defining an object. Has anyone experienced this problem?

The only reason this would happen is if the group is not valid.

Instead of this:

display.newCircle( [parent,] xCenter, yCenter, radius )

do this

local isValid( parent and type(parent.removeSelf) == "function" ) print( "parent is valid", isValid ) display.newCircle( parent, x, y, r ) -- obviously use whatever values you normally do

My guess is you’ll see this:

parent is valid false

The only reason this would happen is if the group is not valid.

Instead of this:

display.newCircle( [parent,] xCenter, yCenter, radius )

do this

local isValid( parent and type(parent.removeSelf) == "function" ) print( "parent is valid", isValid ) display.newCircle( parent, x, y, r ) -- obviously use whatever values you normally do

My guess is you’ll see this:

parent is valid false