How to transition off each object from left to right

In my puzzle block game, when each row or column is filled, it creates a fake tile over the real tile and the fake tiles all transition at once and disappears.

What i am trying to achieve is I want to transition each individual tiles and not the whole row or column at once.

 for i=1, #completed do local fakeTile = display.newSprite(uiSheet, {frames={uiSheetInfo:getFrameIndex("tile")}}) fakeTile.x = tiles[completed[i]].x fakeTile.y = tiles[completed[i]].y fakeTile.width = tiles[completed[i]].width fakeTile.height = tiles[completed[i]].height fakeTile:setFillColor(utils.tileColours[colour][1], utils.tileColours[colour][2], utils.tileColours[colour][3]) tileGroup:insert(fakeTile) tiles[completed[i]].tile = 0 tiles[completed[i]].colour = 0 tiles[completed[i]]:setFillColor(utils.defaultColour[1], utils.defaultColour[2], utils.defaultColour[3], utils.defaultColour[4]) -- Then trans trans\_tiles[#trans\_tiles+1] = transition.to(fakeTile, { time=600, xScale=0.01, yScale=0.01, alpha=0, onComplete=function() display.remove(fakeTile) fakeTile = nil checkForShapes() end }) end

Hi @sysads,

I think you can skip the part about creating a new entry in the “trans_tiles” table for each transition. If this code is your overall loop for  creating fake tiles, just create each fake tile (like you are in the first 7 lines within the loop) and then, for each, just do a local transition upon it to transition it out. No real need to do the part below with “trans_tiles[#trans_tiles+1]”.

So, like this:

[lua]

        for i=1, #completed do 

            local fakeTile = display.newSprite(uiSheet, {frames={uiSheetInfo:getFrameIndex(“tile”)}})

            fakeTile.x = tiles[completed[i]].x 

            fakeTile.y = tiles[completed[i]].y 

            fakeTile.width = tiles[completed[i]].width

            fakeTile.height = tiles[completed[i]].height

            fakeTile:setFillColor(utils.tileColours[colour][1], utils.tileColours[colour][2], utils.tileColours[colour][3])

            tileGroup:insert(fakeTile)

            local t = transition.to( fakeTile, {

                time=600, 

                xScale=0.01,    

                yScale=0.01,

                alpha=0,

                onComplete=function()

                    display.remove(fakeTile)

                    fakeTile = nil 

                    checkForShapes()

                end

            })

[/lua]

Brent

Hi @sysads,

I think you can skip the part about creating a new entry in the “trans_tiles” table for each transition. If this code is your overall loop for  creating fake tiles, just create each fake tile (like you are in the first 7 lines within the loop) and then, for each, just do a local transition upon it to transition it out. No real need to do the part below with “trans_tiles[#trans_tiles+1]”.

So, like this:

[lua]

        for i=1, #completed do 

            local fakeTile = display.newSprite(uiSheet, {frames={uiSheetInfo:getFrameIndex(“tile”)}})

            fakeTile.x = tiles[completed[i]].x 

            fakeTile.y = tiles[completed[i]].y 

            fakeTile.width = tiles[completed[i]].width

            fakeTile.height = tiles[completed[i]].height

            fakeTile:setFillColor(utils.tileColours[colour][1], utils.tileColours[colour][2], utils.tileColours[colour][3])

            tileGroup:insert(fakeTile)

            local t = transition.to( fakeTile, {

                time=600, 

                xScale=0.01,    

                yScale=0.01,

                alpha=0,

                onComplete=function()

                    display.remove(fakeTile)

                    fakeTile = nil 

                    checkForShapes()

                end

            })

[/lua]

Brent