I am animating 24 static sprite objects on the screen using time-based animation and am experiencing intermittent stuttering in the animation. The animation is simple - moving objects on a linear-x path and restarting the object on the opposite side of the screen when the object has crossed the screen boundary. Even reducing the set down to 1 object still produces stuttering in the animation when viewed on my iPhone 4. Is there something that I’m doing wrong here?
[code]
function animateStream(event)
local x
local y
local row
local curl
local bgIdx
local lIdx
local tDelta = system.getTimer() - tPrevious
local delta = lSpeed * (60 / tDelta)
tPrevious = system.getTimer()
for i, value in ipairs(l.stream) do
x = l.stream[i].x
y = l.stream[i].y
row = l.stream[i].row
if (row == animateRowsLeft[1] or row == animateRowsLeft[2]) then
x = x + delta
else
x = x - delta
end
if (x > tileThreshold or x < xTileX) then
bgIdx = random(1, 20)
lIdx = random(1, #l.matrix)
if (bgIdx > 3) then
bgIdx = 1
end
l.stream[i][1].currentFrame = bgIdx
l.stream[i][2].currentFrame = lIdx
l.stream[i].l = l.matrix[lIdx]
l.stream[i].lIdx = lIdx
l.stream[i].type = bgIdx
if (x > tileThreshold) then
x = xTileX + delta
else
x = tileThreshold - delta
end
l.stream[i].alpha = 1
l.stream[i][2].alpha = 1
end
l.stream[i].x = x
l.stream[i].y = y
l.stream[i].snapX = x
l.stream[i].row = row
end
end
function gameLoop(event)
– In my project there is a bit of logic here that manipulates variables
animateStream(event)
end
– I am using performWithDelay() instead of an enterframe as suggested in another forum post
– concerning a similar issue in animation stuttering using transition.to()
timerStash.gameLoop = timer.performWithDelay(2, gameLoop, 0)
[/code] [import]uid: 23583 topic_id: 16541 reply_id: 316541[/import]