Hi, newbie here. Can someone please help me with sample code to add randomness to my scrolling images? The goal is for the user to click the mentioned color. I need random colors to scroll. Here is the code: Help please : )
background = display.newImage( “nightstars.png” )
pinkball = display.newImage( “pink.png” )
pinkball.x = display.stageWidth/ 2
pinkball.y = display.stageHeight/ 1
pinkball.xScale = .5
pinkball.yScale = .5
local function scroll()
pinkball.y = pinkball.y -5;
if(pinkball.y <= -1100) then
pinkball.y = 1100;
end
pinkball.y = pinkball.y -1;
if(pinkball.y <= -1100) then
pinkball.y = 1100;
end
end
local options = { “blue.png”, “green.png”, “yellow.png”, “red.png” }
function showball ()
local mr = math.random( 1, 4 )
end
Runtime:addEventListener(“enterFrame”, scroll);
yellowball = display.newImage( “yellow.png” )
yellowball.x = display.stageWidth/ 2
yellowball.y = display.stageHeight/ 1.4
yellowball.xScale = .5
yellowball.yScale = .5
local function scroll()
yellowball.y = yellowball.y -5;
if(yellowball.y <= -1100) then
yellowball.y = 1100;
end
yellowball.y = yellowball.y -1;
if(yellowball.y <= -1100) then
yellowball.y = 1100;
end
end
Runtime:addEventListener(“enterFrame”, scroll);
greenball = display.newImage( “green.png” )
greenball.x = display.stageWidth/ 2
greenball.y = display.stageHeight/ 2.3
greenball.xScale = .5
greenball.yScale = .5
local function scroll()
greenball.y = greenball.y -5;
if(greenball.y <= -1100) then
greenball.y = 1100;
end
greenball.y = greenball.y -1;
if(greenball.y <= -1100) then
greenball.y = 1100;
end
end
Runtime:addEventListener(“enterFrame”, scroll);
blueball = display.newImage( “blue.png” )
blueball.x = display.stageWidth/ 2
blueball.y = display.stageHeight/ 6.1
blueball.xScale = .5
blueball.yScale = .5
local function scroll()
blueball.y = blueball.y -5;
if(blueball.y <= -1100) then
blueball.y = 1100;
end
blueball.y = blueball.y -1;
if(blueball.y <= -1100) then
blueball.y = 1100;
end
end
Runtime:addEventListener(“enterFrame”, scroll);
redball = display.newImage( “red.png” )
redball.x = display.stageWidth/ 2
redball.y = display.stageHeight/ -1
redball.xScale = .5
redball.yScale = .5
local function scroll()
redball.y = redball.y -5;
if(redball.y <= -1100) then
redball.y = 1100;
end
redball.y = redball.y -1;
if(redball.y <= -1100) then
redball.y = 1100;
end
end
Runtime:addEventListener(“enterFrame”, scroll);
orangeball = display.newImage( “orange.png” )
orangeball.x = display.stageWidth/ 2
orangeball.y = display.stageHeight/ -1.5
orangeball.xScale = .5
orangeball.yScale = .5
local function scroll()
orangeball.y = orangeball.y -5;
if(orangeball.y <= -1100) then
orangeball.y = 1100;
end
orangeball.y = orangeball.y -1;
if(orangeball.y <= -1100) then
orangeball.y = 1100;
end
end
Runtime:addEventListener(“enterFrame”, scroll);
[import]uid: 133869 topic_id: 25933 reply_id: 325933[/import]