<!--
{
  "availability" : [
    "iOS: 8.0.0 -",
    "iPadOS: 8.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.10.0 -",
    "tvOS: -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SpriteKit",
  "identifier" : "/documentation/SpriteKit/SKConstraint/positionX(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "SpriteKit"
    ],
    "preciseIdentifier" : "c:objc(cs)SKConstraint(cm)positionX:"
  },
  "title" : "positionX(_:)"
}
-->

# positionX(_:)

Creates a constraint that restricts the x-coordinate of a node’s position.

```
class func positionX(_ range: SKRange) -> Self
```

## Parameters

`range`

The range to restrict the coordinate to.

## Return Value

A new constraint.

## Discussion

Each time constraints are applied, the x-coordinate of the node’s [`position`](/documentation/SpriteKit/SKNode/position) property is clamped so that it lies inside the specified range.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)