Here’s what the Simulator output shows:
01:22:09.478 test:2 01:22:09.478 not nil:This is the story of the last Samurai.:1 01:22:09.478 test:38 01:22:09.478 i:1 is nil. 01:22:09.478 i:2 is nil. 01:22:09.478 i:3 is nil. 01:22:09.478 i:4 is nil. 01:22:09.478 i:5 is nil. 01:22:09.478 i:6 is nil. 01:22:09.478 i:7 is nil. 01:22:09.478 i:8 is nil. 01:22:09.478 i:9 is nil. 01:22:09.478 i:10 is nil. 01:22:09.478 i:11 is nil. 01:22:09.478 i:12 is nil. 01:22:09.478 i:13 is nil. 01:22:09.478 i:14 is nil. 01:22:09.478 i:15 is nil. 01:22:09.478 i:16 is nil. 01:22:09.478 i:17 is nil. 01:22:09.478 i:18 is nil. 01:22:09.478 i:19 is nil. 01:22:09.478 i:20 is nil. 01:22:09.478 i:21 is nil. 01:22:09.478 i:22 is nil. 01:22:09.478 i:23 is nil. 01:22:09.478 i:24 is nil. 01:22:09.478 i:25 is nil. 01:22:09.478 i:26 is nil. 01:22:09.478 i:27 is nil. 01:22:09.478 i:28 is nil. 01:22:09.478 i:29 is nil. 01:22:09.478 i:30 is nil. 01:22:09.478 i:31 is nil. 01:22:09.478 i:32 is nil. 01:22:09.478 i:33 is nil. 01:22:09.478 i:34 is nil. 01:22:09.478 i:35 is nil. 01:22:09.478 i:36 is nil. 01:22:09.478 i:37 is nil. 01:22:09.478 i:38 is nil. 01:22:09.478 not nil:Stuff:2 01:22:09.478 test:5 01:22:09.478 i:1 is nil. 01:22:09.478 i:2 is nil. 01:22:09.478 i:3 is nil. 01:22:09.478 i:4 is nil. 01:22:09.478 i:5 is nil. 01:22:10.139 test:2 01:22:10.139 not nil:This is the story of the last Samurai.:1 01:22:10.139 test:38 01:22:10.139 i:1 is nil. 01:22:10.139 i:2 is nil. 01:22:10.139 i:3 is nil. 01:22:10.139 i:4 is nil. 01:22:10.139 i:5 is nil. 01:22:10.139 i:6 is nil. 01:22:10.139 i:7 is nil. 01:22:10.139 i:8 is nil. 01:22:10.139 i:9 is nil. 01:22:10.139 i:10 is nil. 01:22:10.139 i:11 is nil. 01:22:10.139 i:12 is nil. 01:22:10.139 i:13 is nil. 01:22:10.139 i:14 is nil. 01:22:10.139 i:15 is nil. 01:22:10.139 i:16 is nil. 01:22:10.139 i:17 is nil. 01:22:10.139 i:18 is nil. 01:22:10.139 i:19 is nil. 01:22:10.139 i:20 is nil. 01:22:10.139 i:21 is nil. 01:22:10.139 i:22 is nil. 01:22:10.139 i:23 is nil. 01:22:10.139 i:24 is nil. 01:22:10.139 i:25 is nil. 01:22:10.139 i:26 is nil. 01:22:10.139 i:27 is nil. 01:22:10.139 i:28 is nil. 01:22:10.139 i:29 is nil. 01:22:10.139 i:30 is nil. 01:22:10.139 i:31 is nil. 01:22:10.139 i:32 is nil. 01:22:10.139 i:33 is nil. 01:22:10.139 i:34 is nil. 01:22:10.139 i:35 is nil. 01:22:10.139 i:36 is nil. 01:22:10.139 i:37 is nil. 01:22:10.139 i:38 is nil. 01:22:10.139 not nil:Stuff:2 01:22:10.139 test:5 01:22:10.139 i:1 is nil. 01:22:10.139 i:2 is nil. 01:22:10.139 i:3 is nil. 01:22:10.139 i:4 is nil. 01:22:10.139 i:5 is nil.
-- show() function scene:show( event ) local sceneGroup = self.view local phase = event.phase if ( phase == "will" ) then -- Code here runs when the scene is still off screen (but is about to come on screen) elseif ( phase == "did" ) then -- Code here runs when the scene is entirely on screen transition.fadeIn(bg, { time = 5000 }) Dialogue.TextBlock({ [1] = "This is the story of the last Samurai.", [2] = "Stuff" }, 500, 300, 2500, 72, 1, 1, 1) end end
And from a Dialogue.lua:
function TextFader(MSG, X, Y, SPEED, SIZE, R, B, G) local textblock = display.newText( MSG, X, Y, native.systemFont, SIZE ) textblock.alpha = 0 textblock:setFillColor( R, B, G ) transition.fadeIn(textblock, {time = SPEED}) local function afterTimer() transition.fadeOut(textblock, {time = SPEED}) end timer.performWithDelay(SPEED \* 2, afterTimer, 1) end function TextBlock(MSG, X, Y, SPEED, SIZE, R, B, G) --MSG should be an array print("Size:"..#MSG) for i = 1, #MSG do if (MSG[i] == nil) then print("i:"..i.." is nil.") else print("not nil:"..MSG[i]..":"..i) -- (SPEED + (SPEED \* 2) + SPEED) \* i timer.performWithDelay(100, TextBlock(MSG[i], X, Y+(SIZE\*i), SPEED, SIZE, R, B, G), 1) --Initial message must show then timer must stack so not everything appears at once in the array. end end end Dialogue.Textshake = Textshake Dialogue.TextFader = TextFader Dialogue.TextBlock = TextBlock