Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Display lines of transition.fadeIn text in sequence
Started by rootuid Apr 22 2019 03:52 PM

2 replies to this topic
[TOPIC CONTROLS]
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

rootuid

[GLOBAL: userInfoPane.html]
rootuid
  • Observer

  • 21 posts
  • Corona SDK

Hi,

I want to display 3 of lines of text and if it's a certain time display the 4th.

 

My code looks like this

local firstLine = display.newText("first line",background.x,40, "sega.ttf", 25)
local secondLine = display.newText("second line",background.x,90, "sega.ttf", 25)
local thirdline = display.newText("third line",background.x,135, "sega.ttf", 25)
local fourthLine = display.newText("4th line",background.x,200, "sega.ttf", 25)

transition.fadeIn( firstLine, { time=2000 } )
transition.fadeIn( secondLine, { delay=2000,time=1000 } )
transition.fadeIn( thirdline, { delay=3000,time=1000 } )

if date.hour >= 1 and date.hour <18 then
        transition.fadeIn( fourthLine, { delay=8000,time=1000 } )
The problem is the 4th line is displayed immediately. I'm thinking I need to create functions for each line and once the first completes move onto the second or something like this? I saw transition.to but not sure if that is the right direction.
 
Any advice would be much appreciated :)
Thanks,
D.

 



[TOPIC: post.html]
#2

roaminggamer

[GLOBAL: userInfoPane.html]
roaminggamer
  • Corona Geek

  • 7,544 posts
  • Corona SDK

set all alphas to 0 before the calls to fadein



[TOPIC: post.html]
#3

rootuid

[GLOBAL: userInfoPane.html]
rootuid
  • Observer

  • 21 posts
  • Corona SDK

I updated my code following roaming gamer's advice 

local background = display.newImageRect( "background.png", display.actualContentWidth, display.actualContentHeight)
local x =1

background.x = display.contentCenterX
background.y = display.contentCenterY

print (background.x)

local firstLine = display.newText("first line",background.x,150, native.systemFont,100)
local secondLine = display.newText("second line",background.x,250, native.systemFont,100)
local thirdline = display.newText("third line",background.x,350, native.systemFont,100)

firstLine.alpha = 0
secondLine.alpha = 0
thirdline.alpha = 0

transition.fadeIn( firstLine, { time=2000 } )
transition.fadeIn( secondLine, { delay=2000,time=1000 } )
transition.fadeIn( thirdline, { delay=3000,time=1000 } )

if x <10 then
	local fourthLine = display.newText("4th line",background.x,550, native.systemFont,100)
	fourthLine.alpha = 0

    transition.fadeIn( fourthLine, { delay=8000,time=1000 } )
end

and sure enough the 4th line is displayed properly.

 

Many thanks.




[topic_controls]
[/topic_controls]