slider
fun slider(a: RigidBody, b: JointEnd, x: Float, y: Float, axisX: Float, axisY: Float): Joint(source)
Lets b slide against a only along the axis (axisX, axisY) through the world point (x, y), as the two lie now, and not turn against it, and returns the joint's handle: a bead on a wire. Pass the arguments by name.
Throws
Samples
val world = PhysicsWorld()
val bead = world.rigidBody(Shape.circle(4f), x = 0f, y = 0f)
// Slides along a 45-degree track through where it is now.
world.joints.slider(bead, JointEnd.WORLD, x = 0f, y = 0f, axisX = 1f, axisY = 1f)
repeat(30) { world.step(1.seconds / 60) }
val x = world.rigidBodies.xOf(bead)
val y = world.rigidBodies.yOf(bead)
assertTrue(y > 10f && kotlin.math.abs(x - y) < 0.5f)Content copied to clipboard