My game has a function that spawns scooters at the left side of the screen, at random y coordinates, that then zip to the right side of the screen. The code is below. This works great, except for when two scooters happen to wind up with the same y coordinate. It’s difficult to explain, but I have a “leveling” function that stacks each scooter based on their y coordinate. When two scooters share the same y coordinate, they “flicker” when passing through each other. This is what I want to avoid. I want to make it so that the random y coordinate generated by my spawn function never duplicates itself (at least until the scooter with that specific y coordinate has removed itself). I hope I’m explaining myself well enough here. Any help would be much appreciated.
Thank you in advance,
Steven
local randTime = math.random( 500, 10000 ) function scooterFunction() local scooter = display.newImage("scooter.png") scooter.x = -100 scooter.y = math.random(1,1024) transition.to(scooter, {time = math.random(3000,6000), delay = 500, x = scooter.x + 968, onComplete=function() scooter :removeSelf() end})end timer.performWithDelay(randTime, scooterFunction, 0)[/code] [import]uid: 79394 topic_id: 26038 reply_id: 326038[/import]
