Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local selectedDG = display.newGroup()
- local tilesDG = display.newGroup()
- local function animateTile(target)
- -- target.pos gets the position of the selected tile DG so that
- -- we can pull it out of the tilesDG
- local t = tilesDG[target.pos]
- tilesDG.parent:insert(t)
- t.x, t.y = tilesDG:localToContent(t.x, t.y)
- local targetX = selectedDG.numChildren * (t.width + 2)
- local sx, sy = selectedDG:localToContent(targetX, 0)
- transition.moveTo(t , {
- time = 1500,
- x = sx,
- y = sy,
- transition = easing.outElastic,
- onComplete = function()
- selectedDG:insert(t)
- t.x, t.y = targetX, 0
- end
- })
- end
- -- touch event listener for the tiles
- local function handleTileEvent( event )
- local phase = event.phase
- local target = event.target
- if not target.selected then
- -- do some stuff
- elseif phase == "ended" then
- -- do some game logic stuff
- animateTile(target)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement