I would love to see some code to implement an easy text-mp3 sync method.
I’ve been using this method, which is far from convenient: You tap the first words, and stars a transition.to that plays the mp3 and the text animation. Since no one could tell me how to change setTextColor, I just duplicated the text and swapped the alpha in order to simulate color change.
So this should be the how NOT to do it I guess. Sorry.
Download example. (Link should be direct, tell me if you have to wait.)
[lua] media.playSound(“1.mp3”)
media.stopSound()
local bg = display.newRect( 0, 0, display.contentWidth, display.contentHeight )
bg:setFillColor(255,255,255)
– Text
local t1 = display.newText(“WAS the night”, 297, 455, “Baskerville”, 30)
t1:setTextColor( 60, 60, 60 )
t1.alpha=1
local t2 = display.newText(“before Christmas,”, 482, 455, “Baskerville”, 30)
t2:setTextColor( 60, 60, 60 )
t2.alpha=1
local t3 = display.newText(“when all through”, 703, 455, “Baskerville”, 30)
t3:setTextColor( 60, 60, 60 )
t3.alpha=1
local t4 = display.newText(“the house”, 297, 491, “Baskerville”, 30)
t4:setTextColor( 60, 60, 60 )
t4.alpha=1
local t5 = display.newText(“Not a creature”, 297, 528, “Baskerville”, 30)
t5:setTextColor( 60, 60, 60 )
t5.alpha=1
local t6 = display.newText(“was stirring,”, 479, 528, “Baskerville”, 30)
t6:setTextColor( 60, 60, 60 )
t6.alpha=1
local t7 = display.newText(“not even”, 630, 528, “Baskerville”, 30)
t7:setTextColor( 60, 60, 60 )
t7.alpha=1
local t8 = display.newText(“a mouse;”, 740, 528, “Baskerville”, 30)
t8:setTextColor( 60, 60, 60 )
t8.alpha=1
local t9 = display.newText(“The stockings”, 297, 564, “Baskerville”, 30)
t9:setTextColor( 60, 60, 60 )
t9.alpha=1
local t10 = display.newText(“were hung”, 470, 564, “Baskerville”, 30)
t10:setTextColor( 60, 60, 60 )
t10.alpha=1
local t11 = display.newText(“by the chimney”, 604, 564, “Baskerville”, 30)
t11:setTextColor( 60, 60, 60 )
t11.alpha=1
local t12 = display.newText(“with care”, 795, 564, “Baskerville”, 30)
t12:setTextColor( 60, 60, 60 )
t12.alpha=1
local t13 = display.newText(“In hopes”, 297, 600, “Baskerville”, 30)
t13:setTextColor( 60, 60, 60 )
t13.alpha=1
local t14 = display.newText(“that St. Nicholas”, 408, 600, “Baskerville”, 30)
t14:setTextColor( 60, 60, 60 )
t14.alpha=1
local t15 = display.newText(“soon would”, 615, 600, “Baskerville”, 30)
t15:setTextColor( 60, 60, 60 )
t15.alpha=1
local t16 = display.newText(“be there;”, 760, 600, “Baskerville”, 30)
t16:setTextColor( 60, 60, 60 )
t16.alpha=1
– Second Text
local tt1 = display.newText(“WAS the night”, 297, 455, “Baskerville”, 30)
tt1:setTextColor( 255, 0, 0 )
tt1.alpha=0
local tt2 = display.newText(“before Christmas,”, 482, 455, “Baskerville”, 30)
tt2:setTextColor( 255, 0, 0 )
tt2.alpha=0
local tt3 = display.newText(“when all through”, 703, 455, “Baskerville”, 30)
tt3:setTextColor( 255, 0, 0 )
tt3.alpha=0
local tt4 = display.newText(“the house”, 297, 491, “Baskerville”, 30)
tt4:setTextColor( 255, 0, 0 )
tt4.alpha=0
local tt5 = display.newText(“Not a creature”, 297, 528, “Baskerville”, 30)
tt5:setTextColor( 255, 0, 0 )
tt5.alpha=0
local tt6 = display.newText(“was stirring,”, 479, 528, “Baskerville”, 30)
tt6:setTextColor( 255, 0, 0 )
tt6.alpha=0
local tt7 = display.newText(“not even”, 630, 528, “Baskerville”, 30)
tt7:setTextColor( 255, 0, 0 )
tt7.alpha=0
local tt8 = display.newText(“a mouse;”, 740, 528, “Baskerville”, 30)
tt8:setTextColor( 255, 0, 0 )
tt8.alpha=0
local tt9 = display.newText(“The stockings”, 297, 564, “Baskerville”, 30)
tt9:setTextColor( 255, 0, 0 )
tt9.alpha=0
local tt10 = display.newText(“were hung”, 470, 564, “Baskerville”, 30)
tt10:setTextColor( 255, 0, 0 )
tt10.alpha=0
local tt11 = display.newText(“by the chimney”, 604, 564, “Baskerville”, 30)
tt11:setTextColor( 255, 0, 0 )
tt11.alpha=0
local tt12 = display.newText(“with care”, 795, 564, “Baskerville”, 30)
tt12:setTextColor( 255, 0, 0 )
tt12.alpha=0
local tt13 = display.newText(“In hopes”, 297, 600, “Baskerville”, 30)
tt13:setTextColor( 255, 0, 0 )
tt13.alpha=0
local tt14 = display.newText(“that St. Nicholas”, 408, 600, “Baskerville”, 30)
tt14:setTextColor( 255, 0, 0 )
tt14.alpha=0
local tt15 = display.newText(“soon would”, 615, 600, “Baskerville”, 30)
tt15:setTextColor( 255, 0, 0 )
tt15.alpha=0
local tt16 = display.newText(“be there;”, 760, 600, “Baskerville”, 30)
tt16:setTextColor( 255, 0, 0 )
tt16.alpha=0
local function stopNBC()
media.stopSound(“1.mp3”)
end
function t1:tap( event )
media.playSound(“1.mp3”)
transition.to(t1, { time=900, alpha=0 } )
transition.to(tt1, { time=900, alpha=1 } )
transition.to(t1, { delay=920, time=900, alpha=1 } )
transition.to(tt1, { delay=920, time=900, alpha=0 } )
transition.to(t2, { delay=800, time=1000, alpha=0 } )
transition.to(tt2, { delay=800, time=1000, alpha=1 } )
transition.to(t2, { delay=2000, time=400, alpha=1 } )
transition.to(tt2, { delay=2000, time=400, alpha=0 } )
transition.to(t3, { delay=2100, time=700, alpha=0 } )
transition.to(tt3, { delay=2100, time=700, alpha=1 } )
transition.to(t3, { delay=2900, time=400, alpha=1 } )
transition.to(tt3, { delay=2900, time=400, alpha=0 } )
transition.to(t4, { delay=2900, time=700, alpha=0 } )
transition.to(tt4, { delay=2900, time=700, alpha=1 } )
transition.to(t4, { delay=3800, time=400, alpha=1 } )
transition.to(tt4, { delay=3800, time=400, alpha=0 } )
transition.to(t5, { delay=4100, time=700, alpha=0 } )
transition.to(tt5, { delay=4100, time=700, alpha=1 } )
transition.to(t5, { delay=4800, time=400, alpha=1 } )
transition.to(tt5, { delay=4800, time=400, alpha=0 } )
transition.to(t6, { delay=5000, time=600, alpha=0 } )
transition.to(tt6, { delay=5000, time=600, alpha=1 } )
transition.to(t6, { delay=5600, time=400, alpha=1 } )
transition.to(tt6, { delay=5600, time=400, alpha=0 } )
transition.to(t7, { delay=5600, time=700, alpha=0 } )
transition.to(tt7, { delay=5600, time=700, alpha=1 } )
transition.to(t7, { delay=6300, time=400, alpha=1 } )
transition.to(tt7, { delay=6300, time=400, alpha=0 } )
transition.to(t8, { delay=6200, time=700, alpha=0 } )
transition.to(tt8, { delay=6200, time=700, alpha=1 } )
transition.to(t8, { delay=7100, time=400, alpha=1 } )
transition.to(tt8, { delay=7100, time=400, alpha=0 } )
transition.to(t9, { delay=7400, time=600, alpha=0 } )
transition.to(tt9, { delay=7400, time=600, alpha=1 } )
transition.to(t9, { delay=8000, time=400, alpha=1 } )
transition.to(tt9, { delay=8000, time=400, alpha=0 } )
transition.to(t10, { delay=8300, time=600, alpha=0 } )
transition.to(tt10, { delay=8300, time=600, alpha=1 } )
transition.to(t10, { delay=8900, time=400, alpha=1 } )
transition.to(tt10, { delay=8900, time=400, alpha=0 } )
transition.to(t11, { delay=9200, time=500, alpha=0 } )
transition.to(tt11, { delay=9200, time=500, alpha=1 } )
transition.to(t11, { delay=9700, time=300, alpha=1 } )
transition.to(tt11, { delay=9700, time=300, alpha=0 } )
transition.to(t12, { delay=9900, time=500, alpha=0 } )
transition.to(tt12, { delay=9900, time=500, alpha=1 } )
transition.to(t12, { delay=10400, time=400, alpha=1 } )
transition.to(tt12, { delay=10400, time=400, alpha=0 } )
transition.to(t13, { delay=10600, time=700, alpha=0 } )
transition.to(tt13, { delay=10600, time=700, alpha=1 } )
transition.to(t13, { delay=11300, time=400, alpha=1 } )
transition.to(tt13, { delay=11300, time=400, alpha=0 } )
transition.to(t14, { delay=11600, time=1100, alpha=0 } )
transition.to(tt14, { delay=11600, time=1100, alpha=1 } )
transition.to(t14, { delay=12600, time=400, alpha=1 } )
transition.to(tt14, { delay=12600, time=400, alpha=0 } )
transition.to(t15, { delay=12900, time=700, alpha=0 } )
transition.to(tt15, { delay=12900, time=700, alpha=1 } )
transition.to(t15, { delay=13800, time=400, alpha=1 } )
transition.to(tt15, { delay=13800, time=400, alpha=0 } )
transition.to(t16, { delay=13500, time=700, alpha=0 } )
transition.to(tt16, { delay=13500, time=700, alpha=1 } )
transition.to(t16, { delay=14200, time=400, alpha=1 } )
transition.to(tt16, { delay=14200, time=400, alpha=0 } )
end
t1:addEventListener( “tap”, t1 )[/lua] [import]uid: 10426 topic_id: 3622 reply_id: 11065[/import]