Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

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
[TOPIC CONTROLS]
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

troylyndon

[GLOBAL: userInfoPane.html]
troylyndon
  • Contributor

  • 520 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.

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

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?



[TOPIC: post.html]
#2

roaminggamer

[GLOBAL: userInfoPane.html]
roaminggamer
  • Corona Geek

  • 7,253 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




[topic_controls]
[/topic_controls]