Skip to content

Commit 220601d

Browse files
committed
feat: TransformComponent can bind its translate X Y Z to another TransformComponent
1 parent 40e731b commit 220601d

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

fxgl-entity/src/main/kotlin/com/almasb/fxgl/entity/components/TransformComponent.kt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,15 @@ class TransformComponent(x: Double, y: Double, angle: Double, scaleX: Double, sc
434434
direction3D = Point3D(direction3D.x, -sinDeg(rotationX), direction3D.z * cosDeg(rotationX)).normalize()
435435
}
436436

437+
/**
438+
* Binds x,y,z of this component to x,y,z of [other].
439+
*/
440+
fun bindTranslation(other: TransformComponent) {
441+
xProperty().bind(other.xProperty())
442+
yProperty().bind(other.yProperty())
443+
zProperty().bind(other.zProperty())
444+
}
445+
437446
override fun toString(): String {
438447
return "Transform($x, $y, $angle, $scaleX, $scaleY)"
439448
}

0 commit comments

Comments
 (0)