即使有延迟,所有对象也会立即显示...我该怎么办?

Even with delay all objects appear in display at once... what do I do?

local path = pather:getPath(startx,starty, endx,endy)

    if path then
        compPath = display.newGroup();
        for node, count in path:nodes() do
            --timer.performWithDelay( 1000, function (event) 
                print(('Step: %d - x: %d - y: %d'):format(count, node:getX(), node:getY()))
                local tile = display.newRect((node:getX() * 50) - 25, (node:getY() * 50) - 25, 48, 48)
                colorCell(tile, 0, 0, 255)
                tile.alpha = 0

                usleep(500);
                transition.fadeIn( tile, { time=1500 } )
                compPath:insert(tile)
            --end
            --)

        end
   end

我有这条路径,我正在尝试将其显示为动画,但它似乎会立即全部显示,即使有延迟,或者如果我将它放入计时器中以突然出现。我是否必须每秒使用帧率显示它?

我错过了什么?

你没有增加循环中的延迟时间,所以你安排所有你的路径节点在 1 秒内出现。

请记住,循环几乎会立即执行(计算机速度很快)。

试试这个:

if path then
    compPath = display.newGroup();
    local revealInterval = 500
    local revealTimeout = 0
    for node, count in path:nodes() do
        timer.performWithDelay( revealTimeout, function (event)
            local tile = display.newRect((node:getX() * 50) - 25, (node:getY() * 50) - 25, 48, 48)
            colorCell(tile, 0, 0, 255)
            tile.alpha = 0
            transition.fadeIn( tile, { time=1500 } )
            compPath:insert(tile)
        end
        )

        revealTimeout = revealTimeout + revealInterval
    end

结束