Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]

display.newCircle doesn't always accept parent group (results in Runtime Error)
Started by troylyndon Aug 19 2018 05:40 PM

1 reply to this topic
This topic has been archived. This means that you cannot reply to this topic.
[TOPIC: post.html]


[GLOBAL: userInfoPane.html]
  • Contributor

  • 571 posts
  • Corona SDK

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.



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?

[TOPIC: post.html]


[GLOBAL: userInfoPane.html]
  • Corona Geek

  • 7,515 posts
  • Corona SDK

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