From bb4bdd15681a81966ad9cfa2d31be86e22ced8ca Mon Sep 17 00:00:00 2001 From: Eryn Wells Date: Sun, 6 Aug 2017 07:53:23 -0700 Subject: [PATCH] [MetaballsKit] In order to modify the actual Ball instance, you have to reference it by index each time (I think) --- MetaballsKit/Metaballs.swift | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/MetaballsKit/Metaballs.swift b/MetaballsKit/Metaballs.swift index a0769a9..dd024f4 100644 --- a/MetaballsKit/Metaballs.swift +++ b/MetaballsKit/Metaballs.swift @@ -67,22 +67,22 @@ public class Field { public func update() { let selfBounds = bounds - for var ball in balls { + for i in 0.. selfBounds.maxX { - ball.velocity.dx *= -1 + balls[i].velocity.dx *= -1 } if ballBounds.minY < selfBounds.minY || ballBounds.maxY > selfBounds.maxY { - ball.velocity.dy *= -1 + balls[i].velocity.dy *= -1 } } }