I have a timer ‘spawning’ items every second.
The ‘spawning’ functions has this code
local fnRandomBall = function()
counter = math.random(100)
if counter \> 80 then
local rndBall = display.newImage( "ball\_orange.png" )
rndBall.x = 40 + math.random( 240 ); rndBall.y = 10
physics.addBody( rndBall, { ballBody } )
rndBall.myName = "orange"
rndBall.isHit = false
transition.to(rndBall, {time=ballSpeed, y=360})
else
local rndBall = display.newImage( "ball\_blue.png" )
rndBall.x = 40 + math.random( 240 ); rndBall.y = 10
physics.addBody( rndBall, { ballBody } )
rndBall.myName = "blue"
rndBall.isHit = false
transition.to(rndBall, {time=ballSpeed, y=360})
end
* I actually have more than 2 balls, but just for illustration, I’m setting a simple IF/Else.
Every time the game starts, it will always start with blue; even if you retry playing again or if you restart simulator or device. [import]uid: 7856 topic_id: 4648 reply_id: 304648[/import]

[import]uid: 7856 topic_id: 4648 reply_id: 14765[/import]