Scene like transitions in Layer?

Why there is no scene like transition for layers?

Is it possible for this feature to be included on layers for the next version
or can anyone tell me the way around for now?

Thanxx :smile:

May I ask why you need to do transitions within layers? Maybe thereā€™s another way to achieve what you want?

Because transition in layers gives advance actions to be performedā€¦

I understand why the notion of layer exists in cocos2d-x but I can use this same layer concept to make a pop-up menu with smaller size and having touch which disables the underneath layerā€™s touch and make the underneath layer a little fade so that focus remains on the pop-up menu(formed using layer)ā€¦

And now, when I press cancel button on this pop up menu, I can put custom action like Flip and Fade out!!
But with current actions I cannot flip or use other transition effects!!

hi @code_game_chef

what you are basically saying is something similar to lightbox in web designing.
when you click on an image that image appears on the top of the webpage when the background is faded, something like the image below rightā€¦ !!

well, if it is only this case
then you can create a menu item something like this -

auto popUpLayer = MenuItemImage::create("img.png", "img.png", [&] (cocos2d::Ref *pSender) {
// create a layer here
});

then check whether the touch is within the layer by its boundingbox and contains points (touch)
if within then return false and delete the layer on true.
something like thatā€¦ that iā€™ve made in the last game.

But that is also relative to a lot of things.
but you can try thatā€¦

and i guess, you can perform acitons on layers also, because they are also nodes and actions can be done on any node.
so you could get the effect. Use something from the ActionEase

Other than that, I am not sure how transitions can be used for layersā€¦

If you have some cool ideasā€¦ you are always welcome to share.
Happy coding :smile:

1 Like

There are actions called FlipX3D and FlipY3D that I believe will do what you want. You would just need to combine these with a fade or a scale or a move to get the effect you want. No need for a separate layer.

@pabitra

  1. Yes, we can perform actions to the layers like others node, not sure of the scene though :smiley:
  1. Yes, it is simiar to what you said ā€œlightboxā€.
    I want the below thingā€¦ and when I press cancel on it. I want effects like that on sceneā€¦

  1. So, you r solution is to use Menu Sprite!! right?
    So, instead of popping layer I would be having popping up sprite :smile:
    Other way is using layer with custom sizeā€¦ Although your way is betterā€¦

Can you explain what is this code for?
Is it to click a button on my menu, and then some layer will pop up.
How to use pSender? Is this pSender same as ā€˜thisā€™ keyword

auto popUpLayer = MenuItemImage::create("img.png", "img.png", [&] (cocos2d::Ref *pSender) {
// create a layer here
});

@toojuice

hehe, yes, I was expecting that you would tell me to use FlipX3D and all but actually my point was that what if I want the cool effects that are made for scene and not other nodes likes layers!!

Sorry, I didnā€™t mean to tell you something obvious. Wasnā€™t sure that you knew about it. I guess Iā€™m having trouble envisioning something that you can do with a transition that you canā€™t do with an action.

hi @code_game_chef

Let me explain you, as per my understanding.
Say thereā€™s a button on your game scene, assume it as a sprite, which on touch will give you info about your game. (just grab the thought)

Now, that sprite is nothing but a MenuItemImage, which has a function callback.
i.e. when the sprite is touched then a function will be called.

Next step -
You touched the sprite, then the function will be called defined in MenuItemImage
inside the definition of the function
create a layer with the size you want
for our example say = visibleSize.width/2, visibleSize.height/2 is the dimention of the layer
set itā€™s position and z-order.

to that layer add another MenuItmImage which contains the close icon sprite.
define itā€™s functionality to remove itā€™s parent when touched.
in this wayā€¦ when you touch the close icon sprite, then the layer will be destroyed and along with it all the children.

Now, if you are more adventerous then do this -
if layer->getBoundingBox.containsPoint(touch)
then return false
else return true

and when the touch is outside the layer, then destroy the layer.
Itā€™s just a rough exampleā€¦ try to make it as smooth as you could.

and yesā€¦ the pSender is the target node, this for the current class object.
i am just using cocos structure of coding, so didnā€™t change the name.

Happy Coding. :smile:

1 Like