CORONASDK Groupobject Group Object

Source: Internet
Author: User

1 overview

The newgroup, whose root stage is the parent of all the people in the group.

The group can be the parent of the image, text, and other Displayobject, and can also be nested within the group's parent layer.

2 coordinate system

The default coordinate for the new group is (0,0), which is located in the upper-left corner of the stage.

3 Drawing Mode

A group is like a piece of paper, displayobject as it is painted (the object moves with the paper). Multiple group stacks, such as multiple sheets of paper, similar to layering.

Pedagogical gardening If you want to format landscape painting, it may be divided into three layers as follows:

A vision: Including the sky, clouds, etc.

B Close-up: including background peaks

C foreground: Including trees, flowers and stones

The three layers are stacked in front and back, and of course each layer can be understood as a paper with a transparent background (layer).

4 Creation Group

Local MyGroup = Display.newgroup ()

To insert a displayobject into a group, there are no more than two methods:

Local rect = display.newrect (0, 0, 40, 40)
Mygroup:insert (Rect)

Local rect = Display.newrect (mygroup, 0, 0, 40, 40)

5 Sets of levels

New group under, post-build group on:

Local farbackground = Display.newgroup ()
Local nearbackground = Display.newgroup ()--this'll overlay ' farbackground '
Local foreground = Display.newgroup ()--and This would overlay ' nearbackground '

Note: The number of members in the group can only be used Group.numchildren, but not #group

6 Delete Group

Delete Group Object nothing But mygroup:removeself () or display.remove (mygroup)

Then remember to dismiss the reference, namely Mygroup=nil

Assuming that the MyGroup contains other sub-objects (Displayobject or Groupobject), the sub-object is also automatically called to delete the function, but the reference to the child object must also be self-assigning nil.

7 Sub-properties of a group

When you modify the group's sub-properties, the object (Displayobject or Groupobject) in all groups is modified. Non-group has attributes, but child objects have attributes, you can change the child object properties from the group level.

For example: Group.alpha = 0.5, does not mean that the set group has an alpha attribute of 0.5, but instead modifies the alpha of all sub-objects under group 0.5. You can also fix the group of sub-properties including displacements and rotations.

8 Sets of transformations

As above, group transformations are applied to all child members of the group. The position of a group member is actually a position (relative coordinate) relative to the parent, and when you transform a group, its children are transformed.

Local MyGroup = Display.newgroup ()

Local mybox = display.newrect (100, 100, 80, 80)
Mybox:setfillcolor (1, 0, 0, 0.8)
Mygroup:insert (Mybox)

If you change the position of the MyGroup:

mygroup.x = 50
MYGROUP.Y = 50

conclusion, at a glance.

No matter what transformations you make to the group (moved/scaled/rotated), you can work out the global coordinates of an actual object by Object:localtocontent ().

Local Actualboxx, Actualboxy = Mybox:localtocontent (0,0)
Print (Actualboxx, actualboxy)

9 Groups and Anchor points

Because the group has no size boundaries, anchor points are generally not considered. It really needs to be considered, it will be the boundary with the overall maximum boundary of the object, the simple graph is as follows:

Mygroup.anchorchildren = True

It is generally not necessary to consider this scenario, just put the current group in a parent group (parent), only need to transform the parent to achieve the same effect.

10 Off-screen removal

Corona will remove the displayobject from the screen surface when rendering.

CORONASDK Groupobject Group Object

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.