I found that I did not have to use a table to do this, I merely just detected when they were out of a certain range, than re-positioned them, but the problem still occurs:
--new code manageAsteroids = function(self) --enterFrame listener for each asteroid if (not display.isValid(self)) then return end local rawX = mAbs(self.x - asteroidObject.x) local rawY = mAbs(self.y - asteroidObject.y) local rawDistance = mPow(rawX, 2) + mPow(rawY, 2) local trueDistance = mSqrt(rawDistance) if trueDistance \> 2625 then local randomX = mRand(-2625, 2625) local randomY = mRand(-2625, 2625) if (((randomX \> fullw - centerX + 150) or randomX \< -(fullw - centerX + 150)) or ((randomY \> fullh - centerY + 90) or (randomY \< -(fullh - centerY + 90)))) then local rawX2 = mAbs(centerX - randomX) local rawY2 = mAbs(centerY - randomY) local trueDistance2 = mSqrt(rawX2 \* rawX2 + rawY2 \* rawY2) if trueDistance2 \< 2625 then self.x = asteroidObject.x + randomX self.y = asteroidObject.y + randomY end end end end
Log: Jan 24 04:14:15.445 FPS = 60 Jan 24 04:14:16.567 FPS = 59.3 Jan 24 04:14:17.685 FPS = 59.9 Jan 24 04:14:18.804 FPS = 59.7 Jan 24 04:14:19.925 FPS = 59.9 Jan 24 04:14:21.046 FPS = 59.5 Jan 24 04:14:22.165 FPS = 59.9 Jan 24 04:14:23.284 FPS = 59.5 Jan 24 04:14:24.405 FPS = 59.7 Jan 24 04:14:25.525 FPS = 59.9 Jan 24 04:14:26.645 FPS = 60 Jan 24 04:14:27.766 FPS = 60 Jan 24 04:14:28.886 FPS = 59.7 Jan 24 04:14:30.005 FPS = 60 Jan 24 04:14:31.124 FPS = 59.7 Jan 24 04:14:32.246 FPS = 60 Jan 24 04:14:33.366 FPS = 59.9 Jan 24 04:14:34.486 FPS = 59.7 Jan 24 04:14:35.606 FPS = 59.5 Jan 24 04:14:36.727 FPS = 60 Jan 24 04:14:37.846 FPS = 59.8 Jan 24 04:14:38.967 FPS = 60 Jan 24 04:14:40.086 FPS = 59.7 Jan 24 04:14:41.207 FPS = 60 Jan 24 04:14:42.327 FPS = 59.9 Jan 24 04:14:43.446 FPS = 59.8 Jan 24 04:14:44.566 FPS = 60 Jan 24 04:14:45.686 FPS = 59.7 Jan 24 04:14:46.807 FPS = 59.5 Jan 24 04:14:47.927 FPS = 60 Jan 24 04:14:49.047 FPS = 59.8 Jan 24 04:14:50.166 FPS = 59.7 Jan 24 04:14:51.287 FPS = 60 Jan 24 04:14:52.407 FPS = 59.8 Jan 24 04:14:53.528 FPS = 60 Jan 24 04:14:54.648 FPS = 59.7 Jan 24 04:14:55.766 FPS = 59.8 Jan 24 04:14:56.888 FPS = 60 Jan 24 04:14:58.009 FPS = 59.7 Jan 24 04:14:59.131 FPS = 59.9 Jan 24 04:15:00.252 FPS = 59.9 Jan 24 04:15:01.371 FPS = 59.8 Jan 24 04:15:02.493 FPS = 59.9 Jan 24 04:15:03.614 FPS = 59.8 Jan 24 04:15:04.734 FPS = 59.7 Jan 24 04:15:05.855 FPS = 58.6 Jan 24 04:15:06.977 FPS = 59.7 Jan 24 04:15:08.110 FPS = 57.9 Jan 24 04:15:09.264 FPS = 56.3 Jan 24 04:15:10.451 FPS = 55.9 Jan 24 04:15:11.584 FPS = 54 Jan 24 04:15:12.774 FPS = 49.1 Jan 24 04:15:14.030 FPS = 47 Jan 24 04:15:15.220 FPS = 56.1 Jan 24 04:15:16.464 FPS = 55.8 Jan 24 04:15:17.957 FPS = 46.4 Jan 24 04:15:19.506 FPS = 48.2 Jan 24 04:15:20.777 FPS = 53 Jan 24 04:15:22.277 FPS = 49.2 Jan 24 04:15:23.797 FPS = 46.2 Jan 24 04:15:25.554 FPS = 38.9 Jan 24 04:15:27.387 FPS = 33.2 Jan 24 04:15:29.382 FPS = 30.8 Jan 24 04:15:31.431 FPS = 32 Jan 24 04:15:33.433 FPS = 39.2 Jan 24 04:15:35.676 FPS = 31 Jan 24 04:15:37.888 FPS = 32.1 Jan 24 04:15:40.045 FPS = 29.6 Jan 24 04:15:42.320 FPS = 30.7 Jan 24 04:15:44.545 FPS = 31.9 Jan 24 04:15:46.800 FPS = 31.3 Jan 24 04:15:49.124 FPS = 27.2 Jan 24 04:15:51.442 FPS = 27.4 Jan 24 04:15:53.713 FPS = 32.8
Currently, I have an enterFrame listener for each asteroid.
Would it be better to put the enterFrame, or even a timer, on one table filled with the asteroids, and just traverse the table, and then reposition them. Could this work?
Also, I noticed that System Memory continuously increases.