How to make shining stars?

I can not make stars. Ordinary stars on a black background, but how to make them shine? That is, so that they burned something, they were extinguished. Please give me the code or the source. 

I try this:

The “function” creates stars, then through “While” I create 50 stars and through “transition.to(alpha)” I make the effect of radiance, but this effect affects all the stars. I need the stars to shine scatter as if they were real.

And can we make them move? That is, they have a background. It is necessary for the background to move.

You probably understand that this is a game about a star ship. 

P.S. If there are errors I apologize! 

Show us what you mean,  attach and image(s) and/or video(s) links.

Define ‘shine’.  What this means to you may not mean the same to us.  

You can’t assume your idea of ‘real’ is our idea of ‘real’.

We need a lot more details and more clearly (bullet lists and paragraphs are nice) laid out.

So, it sounds like you want the alpha of the stars to vary randomly and independently; maybe you mean twinkle instead of shine?

There are many ways to do this, but here’s one:

star.png

local function twinkleStar(whichStar) transition.to( whichStar , { time=whichStar.twinkleTime, alpha=whichStar.alphaMin, transition=easing.continuousLoop, onComplete=function()twinkleStar(whichStar)end} ) end local myStars={} for i=1, 100 do local starSize = 10+math.random()\*20 myStars[i] = display.newImageRect( "star.png", starSize, starSize ) myStars[i].x = (starSize\*.5)+math.random()\*(display.contentWidth-starSize) myStars[i].y = (starSize\*.5)+math.random()\*(display.contentHeight-starSize) myStars[i].alphaMin = math.random()\*.5 myStars[i].alpha = 1 myStars[i].twinkleTime = 2000+math.random()\*4000 twinkleStar(myStars[i]) end

star.png

Stop all that that transition stuff and just use a particle emitter.   It is what it is designed for and it will always be way more efficient than your lua code.

Hey @SGS! That’s true, I was just hoping @eod21 could learn something about why he wasn’t getting the result he wanted.

Show us what you mean,  attach and image(s) and/or video(s) links.

Define ‘shine’.  What this means to you may not mean the same to us.  

You can’t assume your idea of ‘real’ is our idea of ‘real’.

We need a lot more details and more clearly (bullet lists and paragraphs are nice) laid out.

So, it sounds like you want the alpha of the stars to vary randomly and independently; maybe you mean twinkle instead of shine?

There are many ways to do this, but here’s one:

star.png

local function twinkleStar(whichStar) transition.to( whichStar , { time=whichStar.twinkleTime, alpha=whichStar.alphaMin, transition=easing.continuousLoop, onComplete=function()twinkleStar(whichStar)end} ) end local myStars={} for i=1, 100 do local starSize = 10+math.random()\*20 myStars[i] = display.newImageRect( "star.png", starSize, starSize ) myStars[i].x = (starSize\*.5)+math.random()\*(display.contentWidth-starSize) myStars[i].y = (starSize\*.5)+math.random()\*(display.contentHeight-starSize) myStars[i].alphaMin = math.random()\*.5 myStars[i].alpha = 1 myStars[i].twinkleTime = 2000+math.random()\*4000 twinkleStar(myStars[i]) end

star.png

Stop all that that transition stuff and just use a particle emitter.   It is what it is designed for and it will always be way more efficient than your lua code.

Hey @SGS! That’s true, I was just hoping @eod21 could learn something about why he wasn’t getting the result he wanted.