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
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
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!!
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
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
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
});
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.
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.