have several containers

How can i have several container and that one is independent of the other.

I need the second rectangle (u) is not seen on the first container ®

Thank you.

w=display.newRect(0,0,800,600)

w.x=400; w.y=300

w.alpha=0.2

r=display.newContainer(200,200)

r.x=600

r.y=200

v=display.newRect(0,0,40,40)

r:insert(v)

e=display.newContainer(200,200)

e.x=200

e.y=200

u=display.newRect(0,0,40,40)

e:insert(u)

transition.to( u, {time=6000, x=700} )

transition.to( v, {time=6000, x=-700} )

I don’t know what you are trying to achieve but if you want one object to show over the other you have to create them in the right order (bottom first, top last) or call toFront on the object you want on top like topObject:toFront().

Alternatively you can also send object to the bottom of z order with object:toBack(). Note that if the object is in a group it will just go in front or behind objects in that group/container, so if you want the whole group to go on top call toFront() on the group.

Thank you for your aswer, but i want that the rectangle “u” isn’t visible when it where out of it own container.

It should be visible only when to x=0 to x=-200.

I see that the first container it is OK, but the second is wrong

Thank you

Note that coordinates in container are center based so x= 0, y= 0 will put it in the center of the container. Thus rect u will be visible from -100 <= x <= 100.

I tried your code and it behaves as expected. I changed it a little bit to fit a smaller content area.

w=display.newRect(0,0,800,600) w.x=display.contentCenterX; w.y=display.contentCenterY w.alpha=0.2 r=display.newContainer(100,100) r.x=display.contentCenterX r.y=50 v=display.newRect(0,0,40,40) r:insert(v) e=display.newContainer(100,100) e.x=display.contentCenterX e.y=200 u=display.newRect(0,0,40,40) e:insert(u) transition.to( u, {time=6000, x=100} ) transition.to( v, {time=6000, x=-100} )

thanks, but try this code first with the first two lines in comment. The line “A” does not enter the “B” but “B” is in the “A”.

Now activate the first two lines and it works as I want, but do not know why.

Sorry for my English

– local myText = display.newText( “Display A”, 250, 240, native.systemFont, 16 )

– local myText = display.newText( “Display B”, 400, 240, native.systemFont, 16 )

w=display.newRect(0,0,800,600)

w.x=display.contentCenterX; w.y=display.contentCenterY

w.alpha=0.2

r=display.newContainer(100,100)

r.x=display.contentCenterX

r.y=150

v=display.newRect(0,0,5,150)

v.anchorY=-1

r:insert(v)

e=display.newContainer(100,100)

e.x=display.contentCenterX - 150

e.y=150

u=display.newRect(0,0,5,150)

u.anchorY=-1

e:insert(u)

function next0() transition.to( u, {time=6000, delta=true, rotation=360,onComplete=next0} ) end

function next1() transition.to( v, {time=6000, delta=true, rotation=360, onComplete=next1} ) end

next0()

next1()

Ah yes I see your point. This is a bug. With the lines commented it is completely wrong. You should not be able to see the container squares at all. It seems the container masks are not correctly initialized and as text object use masks also it appears that text initializes masking properly. I think I recall something about this from a long time ago so it might be an old bug.

I don’t know what you are trying to achieve but if you want one object to show over the other you have to create them in the right order (bottom first, top last) or call toFront on the object you want on top like topObject:toFront().

Alternatively you can also send object to the bottom of z order with object:toBack(). Note that if the object is in a group it will just go in front or behind objects in that group/container, so if you want the whole group to go on top call toFront() on the group.

Thank you for your aswer, but i want that the rectangle “u” isn’t visible when it where out of it own container.

It should be visible only when to x=0 to x=-200.

I see that the first container it is OK, but the second is wrong

Thank you

Note that coordinates in container are center based so x= 0, y= 0 will put it in the center of the container. Thus rect u will be visible from -100 <= x <= 100.

I tried your code and it behaves as expected. I changed it a little bit to fit a smaller content area.

w=display.newRect(0,0,800,600) w.x=display.contentCenterX; w.y=display.contentCenterY w.alpha=0.2 r=display.newContainer(100,100) r.x=display.contentCenterX r.y=50 v=display.newRect(0,0,40,40) r:insert(v) e=display.newContainer(100,100) e.x=display.contentCenterX e.y=200 u=display.newRect(0,0,40,40) e:insert(u) transition.to( u, {time=6000, x=100} ) transition.to( v, {time=6000, x=-100} )

thanks, but try this code first with the first two lines in comment. The line “A” does not enter the “B” but “B” is in the “A”.

Now activate the first two lines and it works as I want, but do not know why.

Sorry for my English

– local myText = display.newText( “Display A”, 250, 240, native.systemFont, 16 )

– local myText = display.newText( “Display B”, 400, 240, native.systemFont, 16 )

w=display.newRect(0,0,800,600)

w.x=display.contentCenterX; w.y=display.contentCenterY

w.alpha=0.2

r=display.newContainer(100,100)

r.x=display.contentCenterX

r.y=150

v=display.newRect(0,0,5,150)

v.anchorY=-1

r:insert(v)

e=display.newContainer(100,100)

e.x=display.contentCenterX - 150

e.y=150

u=display.newRect(0,0,5,150)

u.anchorY=-1

e:insert(u)

function next0() transition.to( u, {time=6000, delta=true, rotation=360,onComplete=next0} ) end

function next1() transition.to( v, {time=6000, delta=true, rotation=360, onComplete=next1} ) end

next0()

next1()

Ah yes I see your point. This is a bug. With the lines commented it is completely wrong. You should not be able to see the container squares at all. It seems the container masks are not correctly initialized and as text object use masks also it appears that text initializes masking properly. I think I recall something about this from a long time ago so it might be an old bug.