Random image with fade in/out

Hi all, first post here - be gentle!

I am trying to achieve a radom placement of images, with each image then constantly fading in and out.

i am nearly there, i have the images appearing in random positions, the images then fade to alpha 0.5, however only the last image then fades back in to full alpha 1.

My code is below, all help appreciated.

[code] – STAR
local function newStar ( event )
local menuStar = display.newImageRect( “images/star.png”, 11, 10 )
menuStar.x = mRand(50, _W-50); menuStar.y = mRand(50, _H-10);

menuGroup:insert( menuStar )

– STAR FADE ANIMATION
if starIn then
transition.cancel( starIn )
end

local function starFade ()
local starShine = function ()
starIn = transition.to( menuStar, { time=1400, delay=900, alpha=1.0, onComplete=starFade })

end
starIn = transition.to( menuStar, { time=1400, alpha=0, onComplete=starShine })
end

starFade()
end
timer.performWithDelay(1000, newStar, 13)

– END STAR FADE
[/code] [import]uid: 113162 topic_id: 21220 reply_id: 321220[/import]

I think the issue extends with each iteration of the image halting the progress of the previous. if i delay the time until the next image then the cycle continues up until the point of the next image, how can i have the cycle continue regardless of the next image being introduced? Thank you [import]uid: 113162 topic_id: 21220 reply_id: 84037[/import]

Your stars all have the same name; try adding them in a table, eg;

menuStar = {}

local menuStar[#menuStar+1] = display.newImage()

etc.

Peach :slight_smile: [import]uid: 52491 topic_id: 21220 reply_id: 84156[/import]