From 217d9d7bf073137a5e10e9b104ce312693e34e46 Mon Sep 17 00:00:00 2001 From: George Kurelic Date: Wed, 10 Apr 2024 16:17:13 -0500 Subject: [PATCH] fix more pool leaks (#345) --- Other/FlxGameOfLife/source/PlayState.hx | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/Other/FlxGameOfLife/source/PlayState.hx b/Other/FlxGameOfLife/source/PlayState.hx index 6bdf4c377..c65f112e0 100644 --- a/Other/FlxGameOfLife/source/PlayState.hx +++ b/Other/FlxGameOfLife/source/PlayState.hx @@ -13,6 +13,7 @@ import flixel.tile.FlxTilemap; import flixel.ui.FlxButton; import flixel.util.FlxAxes; import flixel.util.FlxColor; +import flixel.util.FlxDestroyUtil; import openfl.display.BitmapData; import openfl.geom.Rectangle; import openfl.ui.Mouse; @@ -419,7 +420,7 @@ class PlayState extends FlxState if (mPos.x >= lifeMap.x && mPos.y >= lifeMap.y && mPos.x < lifeMap.x + lifeMap.width && mPos.y < lifeMap.y + lifeMap.height) { // if the mouse is over the lifeMap, get the tile it is over - var mPosOff:FlxPoint = new FlxPoint((mPos.x - lifeMap.x) / TILE_SIZE, (mPos.y - lifeMap.y) / TILE_SIZE); + final mPosOff = FlxPoint.get((mPos.x - lifeMap.x) / TILE_SIZE, (mPos.y - lifeMap.y) / TILE_SIZE); // if the player just pressed the mouse, set the mouse mode to paint or erase mode, depending on the tile they clicked on if (FlxG.mouse.justPressed) @@ -436,19 +437,20 @@ class PlayState extends FlxState for (points in getLine(Std.int(mPosOffPrev.x), Std.int(mPosOffPrev.y), Std.int(mPosOff.x), Std.int(mPosOff.y))) lifeMap.setTile(points.x, points.y, mouseMode == PAINT ? 1 : 0); - } - - mPosOffPrev = FlxPoint.get(mPosOff.x, mPosOff.y); + else + mPosOffPrev = FlxPoint.get(); + + mPosOffPrev.copyFrom(mPosOff); } else if (FlxG.mouse.released) { // if the player released the mouse, set the mode to none mouseMode = NONE; - mPosOffPrev = null; - + mPosOffPrev = FlxDestroyUtil.put(mPosOffPrev); } updateMouseCursor(true); + mPosOff.put(); } else {