Ambiera Forum

Discussions, Help and Support.

Ambiera Forum > CopperCube > CopperCube Open discussion
Anybody know how to have layer in CC

Aiming bullets
2021-09-06 10:26:09

Do anybody know how to have a better layer system, i have so many 2D overlays one over another but I want some of them to go backward and some of them to come in front during gameplay.
I know i can arrange them up and down and hide or unhide them, but i don't want to hide then and I don't know how to arrange the scenegraph during runtime.

Can anybody @just_in_case, @smnMhmdy @robo or anybody else can create a script that makes a better layers system so that we can make an overlay comes to front and moves to back with just an action.

Thank you!

Registered User
2021-09-06 11:22:42

Not much of a proper layer system but something like this should let you re order nodes to front during runtime:

<action jsname="action_MoveToFront" description="MoveToFront">
<property name="Node" type="scenenode"/>
<property name="IsInRoot" type="bool"/>

action_MoveToFront = function(){
this.Root = ccbGetRootSceneNode();

action_MoveToFront.prototype.execute = function (node){
// leave 'Node' parameter empty to run the action on the current node
var localNodeName = ccbGetSceneNodeProperty(node, "Name");
if(localNodeName) this.Node = node;

// fetching and storing the original parent
var originalParent = this.getParent(this.Node);
var originalParent = this.Root;

// re ordering to the front
var rootChild0 = ccbGetChildSceneNode(this.Root, 0);
ccbSetSceneNodeParent(this.Node, rootChild0);
ccbSetSceneNodeParent(this.Node, originalParent);

action_MoveToFront.prototype.getParent = function(node){
var name = ccbGetSceneNodeProperty(node, "Name");
var p = this.searchForNode(this.Root, node, name);
return (p) ? p : this.Root;

action_MoveToFront.prototype.searchForNode = function(root, node, name){
for(var i = 0, count = ccbGetSceneNodeChildCount(root); i < count; i++){
var currentNode = ccbGetChildSceneNode(root, i);
var currentNodeName = ccbGetSceneNodeProperty(currentNode, "Name");
if(currentNodeName == name && currentNodeName)
return root;
var p = this.searchForNode(currentNode, node, name);
if(p) return p;

2021-09-06 13:04:36

Pretty sure that if you just child an overlay ontop of another (using drag/drop on the scene graph explorer), the root node is always at the front (ontop of the stack), and each child layer is 1 layer back from the previous (underneath the stack)...


2021-09-06 13:07:01

*Sorry, I didn't read your post correctly about changing layer-order during gameplay.

2021-09-07 06:24:56

Thanks @Vp that really helpful...

2021-09-07 08:28:24

can also combine overlay pictures into one big full screen image
one for the moving around mode
one for fighting actions mode
one for .. whatever mode
these are then passive overlays

then have folder for
-moving around with all the overlay controls with transparant picture on them and the attached actions
-fighting folder with their overlay controlls with transparant pictures and attached actions

then you can play them by making these folders visible or not

or would that be sub optimal ??

Create reply:

Posted by: (you are not logged in)

Enter the missing letter in: "Internatio?al" (you are not logged in)




Possible Codes

Feature Code
Link [url] [/url]
Bold [b]bold text[/b]
Image [img][/img]
Quote [quote]quoted text[/quote]
Code [code]source code[/code]



Copyright© 2020 Ambiera e.U. all rights reserved.
Privacy Policy | Terms and Conditions | Imprint | Contact