Im working on a simon says type function, and am having trouble getting the buttons to light up with pauses in between them. This is my code.
local targetDisplay = {}
targetDisplay[1] = display.newImageRect("targetRed.png", 40, 40)
targetDisplay[1].x = 200; targetDisplay[1].y = 300
targetDisplay[1].alpha = .3
targetDisplay[2] = display.newImageRect("targetGreen.png", 40, 40)
targetDisplay[2].x = 260; targetDisplay[2].y = 300
targetDisplay[2].alpha = .3
targetDisplay[3] = display.newImageRect("targetBlue.png", 40, 40)
targetDisplay[3].x = 320; targetDisplay[3].y = 300
targetDisplay[3].alpha = .3
targetDisplay[4] = display.newImageRect("targetYellow.png", 40, 40)
targetDisplay[4].x = 380; targetDisplay[4].y = 300
targetDisplay[4].alpha = .3
targetGroup:insert(targetDisplay[1])
targetGroup:insert(targetDisplay[2])
targetGroup:insert(targetDisplay[3])
targetGroup:insert(targetDisplay[4])
local function flashTarget(self)
local targetHUD = self
targetHUD.alpha = 1
local targetResetTrans = transition.to( targetHUD, { time=100, alpha=.3 } )
end
local function initiateSimon()
local i = 1
for i = 1, roundLength do
numberList[i] = randomNumber[i]
currentTarget = randomNumber[i]
flashTarget(targetDisplay[currentTarget])
end
end
initiateSimon()
I tried adding a timer.performWithDelay to the flashTarget(targetDisplay[currentTarget]) line of code… but it doesnt seem to help… Is there a way to do this with for loops?, or perhaps a better alternative?
[import]uid: 28912 topic_id: 8111 reply_id: 308111[/import]