There are six objects on the screen. The user taps the 3 objects in the order in which they saw it flash on the previous scene.
Here is my code below. Keep I mind the code is pulling from different modules.
local fruitShuffle = require("TableShuffle") local dragFruits = require("dragObject") local fruits = require("fruits") local flashObjects = ("flashObjects") local objectData = require("objectData") local fruitSheet = graphics.newImageSheet( "fruits.png", fruits:getSheet() ) local t = objectData.Fruits shuffle(t) local s = {t[1],t[2],t[3],t[4],t[5],t[6]} -- Shuffle 6 frames order from original Image Sheet shuffle(s) -- Pulling frames from Shuffle table "s" showFruitsSeqData = { {name="S1",sheet=fruitSheet,frames={s[1]} }, {name="S2",sheet=fruitSheet,frames={s[2]} }, {name="S3",sheet=fruitSheet,frames={s[3]} }, {name="S4",sheet=fruitSheet,frames={s[4]} }, {name="S5",sheet=fruitSheet,frames={s[5]} }, {name="S6",sheet=fruitSheet,frames={s[6]} } } -- configure size and placement for each frame store in table data local showFruitsData = { {frameIndex=s[1], width=80, height=80, x=50, y=25}, {frameIndex=s[2], width=80, height=80, x=display.contentCenterX, y=25 }, {frameIndex=s[3], width=80, height=80, x=270, y=25 }, {frameIndex=s[4], width=80, height=80, x=50, y=150 }, {frameIndex=s[5], width=80, height=80, x=display.contentCenterX, y=150 }, {frameIndex=s[6], width=80, height=80, x=270, y=150 } } local fruitsTransition = { {time=1000, x=50 ,y=400, onComplete}, {time=1000, x=display.contentCenterX, y=400, onComplete}, {time=1000, x=270, y=400, onComplete} } local function moveIt(event) for i = 1,#fruitsTransition do transition.to(event.target, fruitsTransition[i] ) return true end end -- Looping the data from the ShowFruitsData Table & enabling objects to to drag for i = 1,#showFruitsData do showFruits = display.newImageRect( fruitSheet, showFruitsData[i].frameIndex, showFruitsData[i].width, showFruitsData[i].height ) showFruits.x=showFruitsData[i].x showFruits.y=showFruitsData[i].y -- transition.to(showFruits, {time=1000, x=display.contentCenterX ,y=400, onComplete} ) -- Add touch sensitivity to object -- showFruits:addEventListener( "touch", dragObj ) showFruits:addEventListener( "tap", moveIt) end
When I tap on the fruits it keep going to the first position. It is not looping to the next transition position.
local fruitsTransition = { {time=1000, x=50 ,y=400, onComplete}, {time=1000, x=display.contentCenterX, y=400, onComplete}, {time=1000, x=270, y=400, onComplete} } local function moveIt(event) for i = 1,#fruitsTransition do transition.to(event.target, fruitsTransition[i] ) return true end end
To get a better idea of what I am trying to do would be the popular 4 Pics 1 Word game. In that game the user tap the letter and each one goes into a sequential position based on the order in which you tap the letter to form a word.
I am trying to figure a way to do this for the objects. Any help will be appreciated. Thanks.