Text color error

I have a function that will change the color of a text once it reaches 5 seconds.

1
2
3
4
5
6
7
8
9
10
11
        local function checkTime (event)
          if active == true then
            if timeRemain <6 and timeRemain~=0 then
               --media.playEventSound(buz)
                   countdowntxt:setTextColor(255,0,0)
                   growTmr = timer.performWithDelay(.00001, grow, 1)
                   growTmr = timer.performWithDelay(200, shrink, 1) 
             end
           end
        end
        codeRed = timer.performWithDelay(1000.0000001, checkTime, 0)

need to see more code

FYI with the tags, you don't go < lua > then < text > - you put your lua code like this;

< lua > here is my code < / lua >

And that's it ;)

As Jstrahan said we really need to see more code than that.

Peach

Hmm... I'm not sure what code to give you. Let me check...

@Joe,
what is countdowntxt? You are trying to set the text colour for that, is it a display object that is definitely not nil?

cheers,

?:)

What is supposed to be happening is there is a timer that is counting down from thirty seconds. And once it reaches 5 it changes from yellow to red, starts flashing, and this robot guy starts counting "5... 4... 3... 2... 1..." Here is all the necessary code. (I think)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
local countdowntxt = display.newText(timeRemain, _W/2, 130, "Helvetica", 30)
 
local function grow (e)
        transition.to(countdowntxt, {time=198, xScale = 2, yScale = 2})
end
        
local function shrink(e)
        transition.to(countdowntxt, {time=198, xScale = 1, yScale = 1})
end
 
local function checkTime (event)
        if active == true then
                if timeRemain <6 and timeRemain~=0 then
                        --media.playEventSound(buz)
                        countdowntxt:setTextColor(255,0,0)
                        growTmr = timer.performWithDelay(.00001, grow, 1)
                        growTmr = timer.performWithDelay(200, shrink, 1) 
                end
        end
end
codeRed = timer.performWithDelay(1000.0000001, checkTime, 0)

Out of interest what version of Corona are you using? (Just wondering if it's a bug with a daily build causing the error or not. Code appears OK.)

Although, OOI, why are you using 1000.0000001?

Peach :)

views:1372 update:2011/11/8 8:33:25
corona forums © 2003-2011