Override vertical layout for one of the child node

Override vertical layout for one of the child node
0
#1

I have a container node with vertical layout (top-bottom). With lots of stacked nodes in it aligned perfectly vertically. And it is scrolling just like a normal chat app.

I would like to add an animation node to that container but not be shown on the bottom and I would like it to follow the positions (x, y) that I set. But this does not happen. The animation node goes to the bottom. I need it to be on top of all the child nodes of the container node.

Is there a way to achieve this?

Thanks!

0 Likes

#2

Are you using Cocos2d-JS or Cocos Creator?

0 Likes

#3

I am using cocos creator. We added the container with layout component.

Then the animation node is programmatically inserted to the container.

0 Likes

#4

Ok I’ll change the category. You should pick Creator in the future.

0 Likes

#5

Ok. Thanks.

0 Likes

#6

you need reset the child node zIndex!(small zIndex will show on the top)
and then call:
this.node.getComponent(cc.Layout).updateLayout();

0 Likes

#7

Hi 11184, thanks. You mean all children of the container node I have to reorder the zIndex?

This will just arrange it in order but I would like one node to be like an overlay of the other nodes.

We have basically a chat app with new text appearing from the bottom just like any other chat apps. This is handled perfectly by the layout component.

We would need to add animations like a smiley face on a specific child node.
If I put the node as a child of that node, this is ok. I could animate nicely.
BUT the issue is when my animation is bigger than the node, it goes behind the node below it because of the layout issue.

So I would like to add the animation node directly to the container node but the animations follows the top-bottom of the container ending up with the animation animating at the bottom.

0 Likes

#8

Hi, managed to do a workaround.

I have moved all my animations to the last child of the container node and adjust the position using convertToWorldSpaceAR then convertToNodeSpaceAR. This imitates like it is over a specific child but actually it’s parent is on the last child (top-bottom).

Hope it helped others with the same issue.

0 Likes