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

# positionX(_:y:)

Creates a constraint that restricts both coordinates of a node’s position.

## Declaration

```swift
class func positionX(_ xRange: SKRange, y yRange: SKRange) -> Self
```

## Parameters

- `xRange`: The range to restrict the x-coordinate to.
- `yRange`: The range to restrict the y-coordinate to.

## Mentioned in

Creating Position Constraints

## Return Value

Return Value A new constraint.

## Discussion

Discussion Each time constraints are applied, the node’s position property is clamped so that both coordinates lie inside the specified ranges.

## See Also

### Creating Position Constraints

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