moving
fun moving(left: Float, top: Float, right: Float, bottom: Float, tags: SolidTags = SolidTags.NONE, material: Material = Material.DEFAULT): Solid(source)
Returns a new solid that is not tied to a grid cell, filling the given edges, for SolidGrid.add. Its top and bottom may change as it moves. Pass the edges by name.
Throws
Samples
val grid = SolidGrid(columns = 20, rows = 20, tileSize = 16f)
// A platform that is not on the grid; move it by changing its top and bottom.
val platform = Solid.moving(left = 32f, top = 200f, right = 96f, bottom = 208f)
grid.add(platform)
val world = PhysicsWorld()
world.solids = grid
val drop = world.particles.add(x = 64f, y = 150f)
repeat(60) { world.step(1.seconds / 60) }
assertTrue(world.particles.yOf(drop) in 199f..200.5f)
assertPrints(grid.moving.size, "1")Content copied to clipboard