Hello.
After a week, I finally got a layout of tiles “diamond” shape.
like a checkerboard for chess but in an ISOMETRIC form
I use the newMask ( ) to stop touching the transparent corners
of my rectangle.
I use object.myID to make sure each tile has a different number
I use for i loop and for j loop so basically 2 functions make the entire
screen layout.
this is my entire code simple 8 diamonds…
local mask = graphics.newMask( "images/m1mask.png" ) local tiles = {} function createBoard1() for i = 1, 2 do for j = 1, 2 do local aTile = display.newImageRect(sceneGroup, "images/m1.png", 128, 64 ) tiles[i] = aTile -- For efficient instead of multiple lookups. aTile:setMask( mask ) aTile.isHitTestMasked = true aTile.x = 128\*(i-1) aTile.y = 64\*(j-1) aTile.myID = (i-1) \* 2 + j -- not sure where your ids are coming from, so I did this aTile.touch = onTouch aTile:addEventListener( "touch" ) end end end createBoard1() local tiles2 = {} function createBoard2() for i = 2, 4 do for j = 2, 4 do local bTile = display.newImageRect(sceneGroup, "images/m2.png", 128, 64 ) tiles2[i] = bTile -- For efficient instead of multiple lookups. bTile:setMask( mask ) bTile.isHitTestMasked = true bTile.x = 128\*((i-1)-1.5) bTile.y = 64\*((j-1)-1.5) bTile.myID = ((i-1)-1) \* 2 + j -- not sure where your ids are coming from, so I did this bTile.touch = onTouch bTile:addEventListener( "touch" ) end end end createBoard2()
and I have the function to detect if it is 5 or 8 or 7
local function onTouch( self, event ) if( event.phase == "began" ) then print("Touched: ", self.myID ) if (self.myID) == 4 then print("is 4") elseif (self.myID) == 7 then print("is 7") end -- end of the if (self.myID) end return end
And it works great!
I can touch each tile and it has a unique number, 1 — 8
QUESTION —
when I touch 4 it prints … “is 4”
so I know that one “IS” 4
but how can I make 4.alpha = .5
or transition.to(4, { time=100…})
or 4.rotation = 45
like that…
I use the
bTile[4].alpha = .5 but is not working
also this
bTile.myID[4].alpha = .5 – Not working
I don’t know how to do this
Thanks for all your help
I think with this much I can make a wonderful educational game
thanks…