How to make block stop moving when touching with other block
local board ={} local blockArray ={"1.png","2.png","3.png","4.png"}; for i=1,6 do board[i]={} for j =1,12 do board[i][j]=display.newRect(0,0,35,35) board[i][j].x = i\*36+30 board[i][j].y = j\*36+15 board[i][j].alpha = 0.05 end end local function moveDown( self) if self. y \> board[3][12].y then self.y = self.y + 0 else self.y = self.y +1.1 end end local function addblocks() local r = math.random(1, #blockArray); local t = math.random(1, #blockArray); local block = display.newImageRect(blockArray[r],35,35); local block2 = display.newImageRect(blockArray[t],35,35); block.x=board[3][2].x block.y=board[3][2].y block2.x=board[3][1].x block2.y=board[3][1].y block.enterFrame = moveDown Runtime:addEventListener("enterFrame" , block) block2.enterFrame = moveDown Runtime:addEventListener("enterFrame" , block2) end addblocks()
Somebody say make the board be 0 and the block be 1 and check if the board is 0 then the block can move down if there are 1 then stop the block but how can I do that.