---
title: "positionX(_:)"
framework: spritekit
role: symbol
role_heading: Type Method
path: "spritekit/skconstraint/positionx(_:)"
---

# positionX(_:)

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

## Declaration

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

## Parameters

- `range`: The range to restrict the coordinate to.

## Mentioned in

Creating Position Constraints

## Return Value

Return Value A new constraint.

## Discussion

Discussion Each time constraints are applied, the x-coordinate of the node’s position property is clamped so that it lies inside the specified range.

## See Also

### Creating Position Constraints

- [Creating Position Constraints](spritekit/creating-position-constraints.md)
- [positionX(_:y:)](spritekit/skconstraint/positionx(_:y:).md)
- [positionY(_:)](spritekit/skconstraint/positiony(_:).md)
