Pergunta

I want 2 sprites on the one index position. The sprites have different coordinates (x attributes), so, each of them are visible when the child position is active.

Clarification, the code:

addChildAt( sprite1, 1 );
addChildAt( sprite2, 1 );   

Are both of the sprites visible?

Foi útil?

Solução 2

No, you can't. But you can add extra sprite between parent and children to easily control visibility or whatever. Sample:

parentSprite.addChild(extra)
extra.addChildAt( sprite1, 1 );
extra.addChildAt( sprite2, 2 );   

Outras dicas

The documentation gives you the answer of what will happen with your snippet.

index:int — The index position to which the child is added. If you specify a currently occupied index position, the child object that exists at that position and all higher positions are moved up one position in the child list.

Two objects can't share the same index because it wouldn't make sense. How would you display two overlapping objects at the same index?

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top