From 74fbbc9df0ed7de82d0e4de2d5cf5cbcc104ad06 Mon Sep 17 00:00:00 2001 From: alestiago Date: Fri, 18 Mar 2022 10:40:43 +0000 Subject: [PATCH] feat: implemented stop and reusme methods --- lib/game/components/ball.dart | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/lib/game/components/ball.dart b/lib/game/components/ball.dart index 36ed8929..0795767c 100644 --- a/lib/game/components/ball.dart +++ b/lib/game/components/ball.dart @@ -61,4 +61,19 @@ class Ball extends BodyComponent with InitialPosition { gameRef.spawnBall(); } } + + /// Immediatly and completly [stop]s the ball. + /// + /// The [Ball] will no longer be affected by any forces, including it's + /// weight and those emitted from collisions. + void stop() { + body.setType(BodyType.static); + } + + /// Allows the [Ball] to be affected by forces. + /// + /// If when previously [stop]ed, the previous ball's velocity is not kept. + void resume() { + body.setType(BodyType.dynamic); + } }