Group

Type    

class (base class : Display)

[gd]

Inheritance

Group ⟶ Display

[bg]

Overview

Group object can contain multiple display objects.


See also 

Display



Overview


  Creates a group that can contain multiple display objects. Note that the basic properties of a Group object effect on the all contained display objects.


  Group class inherits Display class, therefore all the methods defined in Display class can also be used in the Group object.



Syntax



local g = Group()


There is no argument required.


Methods



method

description

return

obj:add(child1, child2,... )

add children (Display object) into obj (Group object). The x and y of the childs are set to zeros when they are added to the group object.

self

obj:getNumChildren()

get total number of added display object

num

obj:getChild(k)

get child object of index k

Display object

obj:clear()

remove all the added children

self


Note that all the methods of Display class are callable.


Examples



local g1 = Group()

local moon = Image('moon.png'):addTo(g1) -- insert moon into g1


local g2 = Group():addTo(g1) -- g2 is inserted into g1 at the time of creation

local star = Star(100)


-- some time later


g2:add(star) -- insert star into g2 group


댓글 없음:

댓글 쓰기