scroll.closestContentLayerForScrollPoint(originX, originY)

Get the content layer closest to a specific point.
译:获取最接近某个特定点的内容层。

scroll = new ScrollComponent

# Create content layers 
layerA = new Layer
    parent: scroll.content
    name: "layerA"
    x: 0
    y: 0

layerB = new Layer
    parent: scroll.content
    name: "layerB"
    x: 50
    y: 50

# Get the layer of which the top-left 
# corner is closest to x: 50, y: 25 
print scroll.closestContentLayerForScrollPoint(
    x: 50
    y: 25
)

# Returns layerB

You can adjust the origin values to define how the distance is calculated. The default values are (0,0). This means that it calculates the distance from the top-left of the ScrollComponent to the top-left of the content layers.
译:您可以调整原点值来定义如何计算距离。默认值是(0,0)。这意味着计算距离的scrollcomponent左上到内容层的左上方。

scroll = new ScrollComponent

# Create content layers 
layerA = new Layer
    parent: scroll.content
    name: "layerA"
    x: 0
    y: 0


layerB = new Layer
    parent: scroll.content
    name: "layerB"
    x: 50
    y: 50

# With the origins set to the center, 
# layerA becomes the closest 
print scroll.closestContentLayerForScrollPoint({ x: 50, y: 25 }, 0.5, 0.5)

# Returns layerA

results matching ""

    No results matching ""