[SOLVED] Moving a layer in a scene affects other layers positions

[SOLVED] Moving a layer in a scene affects other layers positions
0.0 0



I have changed my original post because I have realised it was something different to what I thought.

I have my scene which handles the onMoved messages. In a child layer I am using Actions to move the child layer.

this.popup.runAction(cc.MoveTo.create(.2, cc.p(-200, gamePopups.defs[0].y)));

like so.

Anyway after using the action for some reason th eonMouseMoved event is not the correct mouse position. It seems to be adjusted by the Action from the child layer.


You can have two different ‘type’ of position:

  • World position
  • Node position

World position should be relative to the screen (that is, if you have a 1920x1080 screen, a point with world position will be always in a 1920x1080 rectangle)

Node positions, on the other hand, refer to the parent (or node) which they are in.

You first have to understand which type of touch position you are looking for (fixed for screen = world OR relative to parent = node) and then convert, if you need, among the two.

You can convert using convertToNodeSpace() and convertToWorldSpace() like


Hope this helps!
Let me know :)!


This doesn’t really help. I will try explain better what is happening with my code.

Scene…. I activate mouse movement.

	if( 'mouse' in sys.capabilities ) {

In the scene I pick up the mouse movement events and get the position.

onMouseMoved: function(event) {
var pos = event.getLocation();

This is all working fine. UNTIL… I use the Action on one of my layers

                this.popup.runAction(cc.MoveTo.create(.2, cc.p(x,y)));

Each time I do the above action on that layer the position that comes back in the event on the scene is different. Surely the mouse move event in the scene ( the master layer so to speak ) should be constant. I would understand if it was a mouse movement event on that specific layer but its not its the root node.


OK I have solved this problem.

I handle mouse movement and click control in the main scene handler. I then call into all my child layers to check for any clicking on buttons etc in those layers.

In the specific layer that was causing things to go wrong I had

    if( 'mouse' in sys.capabilities ) {

In the actual layers class. This was obviously causing some issues somewhere and making the mouse movement coordinate system to go mad.