Positioning of created prefabs

I have a prefab.
I have a canvas
canvas Design res is 1920 x 1080.
All els is as it was created (i.e. I haven’t made changes)

When I instantiate a prefab and position it at (0,0) it appears in the center of the screen.

I don’t understand why?

The only clue I have is that the Position is showing as 960 x 540 - which is obviously the center of the screen’s resolution - but that’s locked so it doesn’t look like I have a choice?

Check de anchor point.

Check the anchor point of what?

Canvas has the anchor point at 0.5,0.5, that means the center of the screen. So if you instantiate a prefab and add it as a child it will appear in the center. Then just .setPosition to the desired position. You can change the anchor point if you need to. I highly recommend you to read the manual: http://cocos2d-x.org/docs/editors_and_tools/creator/index.html

So how come when I drag a sprite or a prefab onto the canvas at the bottom left, it has a position of (0,0) which ISN"T at the center.

Oh, and I have read a lot of the manual - I don’t think much of it and certainly it hasn’t helped with this.

When I drag a new sprite/label to the canvas, it goes to center and its position is (0,0). I do not know your setup, but it works for me. If you think it works in a different way in your computer I would suggest you to prepare a test project and submit it to the github repo as an issue. A video on how this is happening for you would also be very helpful.
Regarding the manual: this version is way better than 1.0 (an order of magnitude at least) and it has been very helpful for me.

position property of a node is in it’s parent coordinate space, (0,0) being the paren’t anchor point. It is not a position on the screen, see cc.Node.geNodeToWorldTransform and similar methods.
Canvas is actualy a node with set anchor and position in world space in a way, that it covers the whole screen and it’s anchor point being in the center.
When you drag a prefab into scene in editor it may not have Canvas as parent, it depends on how you actually do it. Also when you drag a node to another parent in editor, it modifies this node’s position property so it would have the same world position. It doesn’t happen automatically in runtime if you just set node’s parent property from code

Yeah, this might be the issue… @Maxxx check the prefab its actually a child of Canvas. Thanks @persy!

I’m not sure IU 100% follow that last bit, but I am guessing this is the difference between adding in code and drag-drop.

I do have a canvas, and when I drag/drop an image onto the canvas, the coordinates of the image show as (0,0) if it is at the bottom left of the canvas.

If I do the same with a prefab in code, position (0,0) is at screen center.

Caveat - it was a 24 hour game jam, and I was tired, so I may have been missing something!!