layer.centerX(offset)
Center this layer horizontally in its parent. If there is no parent it will be centered relative to the screen. The offset is a pixel offset from the center and optional.
译:中心层在超级层中的横向。如果没有超级层将中心相对于屏幕。该偏移量是从该中心和可选的像素偏移。
Arguments(参数)
offset — A number that offsets the position. 译:一个数字,偏移位置。
layerA = new Layer
width: 500
height: 500
layerB = new Layer
parent: layerA
width: 100
height: 100
layerB.centerX()
print layerB.x, layerB.y
# Output: 200, 0
layerB.centerX(20)
print layerB.x, layerB.y
# Output: 220, 0