Hello!!
When I was imitating what’s the developer coding in this video
http://goo.gl/U7U7T
I faced a problem , which is that I can’t touch the “orbs”, because
the ready constant is = false.
this is the code if you can help me !!
[code]–constants
_H = display.contentHeight;
_W = display.contentWidth;
mRand = math.random;
o = 0;
time_remain = 10;
time_up = false;
total_orbs = 20;
ready = false;
–Prepare sounds to be played or accessed
local beepSound = audio.loadSound(“media/beep.wav”);
local winSound = audio.loadSound(“media/TaDa.mp3”);
local failSound = audio.loadSound(“media/whistling.mp3”);
local display_txt = display.newText(“Wait”,0,0,native.systemFont, 16*2);
display_txt.xScale = 0.5; display_txt.yScale = 0.5;
display_txt:setReferencePoint(display.BottomLeftReferencePoint);
display_txt.x = 20; display_txt.y = _H-20;
local countdowntxt = display.newText(time_remain, 0 , 0 , native.systemFont, 16*2)
countdowntxt.xScale = 0.5; countdowntxt.yScale = 0.5;
countdowntxt:setReferencePoint(display.BottomRightReferencePoint);
countdowntxt.x = _W-20; countdowntxt.y = _H-20;
–Defining the track0rbs
local function track0rbs(obj)
obj:removeSelf();
end
local function countDown(e)
if(time_remain == 10) then
ready = true;
end
time_remain = time_remain-1;
countdowntxt.text = time_remain;
end
local function spawn0rb()
local orb = display.newImageRect(“images/sphere-omar.png” , 65 , 65);
orb:setReferencePoint(display.CenterReferencePoint);
orb.x = mRand(50 , _W-50); orb.y = mRand(50 , _H-70);
if(ready == true)then
function orb:touch(e)
if(e.phase == “ended”)then
–Play the beep sound
audio.play(beepSound);
–Remove the orbs
track0rbs(self);
end
return true;
end
end
–Increment o for every orb created
o = o+1;
orb:addEventListener(“touch” , orb);
–If all orbs created, start the game timer
if(o == total_orbs)then
gametmr = timer.performWithDelay(1000 , countDown , 10);
end
end
tmr = timer.performWithDelay(20 , spawn0rb , total_orbs);
[/code]
*sorry for my bad English, because the English is not my first language.
*I’m sure that I do everything that was in the video. [import]uid: 133838 topic_id: 24164 reply_id: 324164[/import]
[import]uid: 122802 topic_id: 24164 reply_id: 97551[/import]