Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

How to make shining stars?
Started by eod21 May 02 2018 06:35 AM

4 replies to this topic
noob corona sdk making stars
[TOPIC CONTROLS]
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

eod21

[GLOBAL: userInfoPane.html]
eod21
  • Observer

  • 1 posts
  • Corona SDK

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! 


[TOPIC: post.html]
#2

roaminggamer

[GLOBAL: userInfoPane.html]
roaminggamer
  • Corona Geek

  • 6,404 posts
  • Corona SDK

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.


Edited by roaminggamer, 02 May 2018 - 08:27 AM.


[TOPIC: post.html]
#3

csavalas

[GLOBAL: userInfoPane.html]
csavalas
  • Contributor

  • 101 posts
  • Corona SDK

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



[TOPIC: post.html]
#4

SGS

[GLOBAL: userInfoPane.html]
SGS
  • Corona Geek

  • 1,734 posts
  • Corona SDK

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.



[TOPIC: post.html]
#5

csavalas

[GLOBAL: userInfoPane.html]
csavalas
  • Contributor

  • 101 posts
  • Corona SDK

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




[topic_controls]
[/topic_controls]

Also tagged with one or more of these keywords: noob, corona sdk, making, stars