[lua] Rand = math.random;
local function randomnumber()
randomn = Rand(0, 10)
print (randomn)
return randomn
end
–randomnumber()
Timerrandom = timer.performWithDelay(1000,randomnumber, 0)
local backgroundtable = {}
local bg1 = {}
bg1 = “1.png”;
table.insert(backgroundtable, bg1);
local bg2 = {}
bg2 = “2.png”;
table.insert(backgroundtable, bg2);
local bg3 = {}
bg3 = “3.png”;
table.insert(backgroundtable, bg3);
local bg4 = {}
bg4 = “4.png”;
table.insert(backgroundtable, bg4);
local bg5 = {}
bg5 = “5.png”;
table.insert(backgroundtable, bg5);
local bg6 = {}
bg6 = “6.png”;
table.insert(backgroundtable, bg6);
local bg7 = {}
bg7 = “7.png”;
table.insert(backgroundtable, bg7);
local bg8 = {}
bg8 = “8.png”;
table.insert(backgroundtable, bg8);
local bg9 = {}
bg9 = “9.png”;
table.insert(backgroundtable, bg9);
local bg10 = {}
bg10 = “10.png”;
table.insert(backgroundtable, bg10);
s1 = {}
local s1 = backgroundtable[randomn]
local s1 = display.newImage(backgroundtable[randomn])
s1.myName = “bg” s1.rotation = 90
s1:setReferencePoint(display.CenterLeftReferencePoint)
s1.x = 160
s1.y = 0
s2 = {}
local s2 = backgroundtable[randomn]
local s2 = display.newImage(backgroundtable[randomn])
– Set image path for object
s2.myName = “bg2”
s2.rotation = 90
s2:setReferencePoint(display.CenterLeftReferencePoint)
s2.x = 160
s2.y = 480
local tPrevious = system.getTimer()
local function move(event)
local tDelta = event.time - tPrevious
tPrevious = event.time
local yOffset = ( 0.15 * tDelta )
s1.y = s1.y - yOffset
s2.y = s2.y - yOffset
if (s1.y + s1.contentHeight-1) < 0 then
s1:translate( 0, 480 * 2)
end
if (s2.y + s2.contentHeight-1) < 0 then
s2:translate(0, 480 * 2)
end
end
Runtime:addEventListener( “enterFrame”, move )[/lua]
I keep getting , attempt to index local ‘s1’ (a nil value)
It works perfect without the timer, how can I fix this?
Any help is much appreciated
if it helps, here is a zip file http://www.mediafire.com/?tnhydtr5pyrnxtn
[import]uid: 23546 topic_id: 12771 reply_id: 312771[/import]