[Plugin] 3D Starfield

Post your completed addons to share with the community

Post » Wed Sep 09, 2015 9:09 am

In any case, it's pretty cool. I'm already making a ptotoype using it, but I decided to use a bunch of webgl so it would never probably run properly on android anyway!

Take a look:
https://www.youtube.com/watch?v=nWjUip0khXs


By the way, would it be possible to add a gradient color option to the background instead of plain black? So it looks like this starfield effect? effect-radial-starfield_t128707?&hilit=starfield
B
125
S
43
G
41
Posts: 849
Reputation: 28,260

Post » Wed Sep 09, 2015 9:12 am

HI once again, thanks for that but could you give me an example to get started please.
I would be very grateful.

Matthew
B
34
S
3
G
1
Posts: 46
Reputation: 1,675

Post » Wed Sep 09, 2015 2:02 pm

Mr @Matthew can you convert this to C2 .. ? If no , i can help you ...

http://phaser.io/examples/v2/demoscene/ ... ath-follow
Last edited by Gigatron on Wed Sep 09, 2015 2:41 pm, edited 1 time in total.
B
69
S
24
G
29
Posts: 829
Reputation: 22,751

Post » Wed Sep 09, 2015 2:39 pm

andreyin wrote:In any case, it's pretty cool. I'm already making a ptotoype using it, but I decided to use a bunch of webgl so it would never probably run properly on android anyway!

Take a look:
https://www.youtube.com/watch?v=nWjUip0khXs


By the way, would it be possible to add a gradient color option to the background instead of plain black? So it looks like this starfield effect? effect-radial-starfield_t128707?&hilit=starfield

great !!
Yes it's possible , but i must rework the code ... understand the base of this plugin...
update routine ();
draw stars..
draw black rect
draw stars
draw black rect
draw stars
draw black rect .... every thick per seconds ... ect etc ..

so if i want gradient , question ? What must i do ?
Answer is :
we must draw gradient instead of "black rect" .... Right ?
can i do this ? YES ...
So tell me what colors you want i can try to do for you ...
B
69
S
24
G
29
Posts: 829
Reputation: 22,751

Post » Wed Sep 09, 2015 3:51 pm

I opened the runtime.js up to try and mess with it myself and I found this part

Image

Is it supposed to be missing a ; at the end? I don't understand javascript much..

The perfect thing for me would be if you could draw a gradient rectangle like this behind the stars
http://www.w3schools.com/tags/canvas_cr ... adient.asp

And have options in the object properties to set the colors, or if the gradient is vertical/horizontal by changing the x1,x2,y1 and y2..

I don't know if this would be possible though, maybe it would be too much intense? I'm not sure..
B
125
S
43
G
41
Posts: 849
Reputation: 28,260

Post » Wed Sep 09, 2015 4:47 pm

Ok you are in the right way ... so i have no time now... but to play with it insert this code


Code: Select all
   function remplie(color)
      {
      //   var tmp = ctx.fillStyle;
      //   var tmp2=ctx.globalAlpha;
      //   ctx.globalAlpha=1.0;
      //   ctx.fillStyle = color;
      //   ctx.fillRect(0, 0, w,h);
      //   ctx.fillStyle = tmp
      //   ctx.globalAlpha=tmp2;
         
         
         var my_gradient = ctx.createLinearGradient(0, 0, 0, h);
            my_gradient.addColorStop(0, '#000000');
            my_gradient.addColorStop(.5, '#FF0000');
            my_gradient.addColorStop(1., '#000000');
 
         ctx.fillStyle = my_gradient;
         ctx.fillRect(0, 0, w, h);
         
      }   

And you have a red gradient ; add colorstop is the start of the top to bottom ... 0 to .5 to .1.0
B
69
S
24
G
29
Posts: 829
Reputation: 22,751

Post » Wed Sep 09, 2015 10:23 pm

Weird, I typed a post but I think I forgot to press "submit" lol

Thanks, this code worked perfectly! I'm trying to mess aroung more with it so I can add these 3 colors in the object properties. This way I could maybe even change it during the runtime probably? :D

Edit:

I got it to work, but I couldn't understand how to make the same action accept 3 parameters.. I tried to take a look at the canvas plugin so I could use it as example but it just blew my mind hahaha.

Here's the edited plugin with custom bg gradient color for the BG, and an action that changes the color in the runtime if anyone wants to use it.

OLD!!

Thanks for the help!

Edit 2:

Found out how to do it, it works fine in my PC but I think it will run extremely laggy on lower-end PCs. Still, it looks great! This is the new version:

NEW!! - https://dl.dropboxusercontent.com/u/238 ... nt_new.zip

It includes the original capx, modified to put a random color every second.

Example:
https://dl.dropboxusercontent.com/u/238 ... index.html
B
125
S
43
G
41
Posts: 849
Reputation: 28,260

Post » Wed Nov 11, 2015 10:20 am

And once again, many thanks.
August 2015 - I misplaced a lot of links - I will try to find backups and repost. If You find a post that interests please reply to post with @rampackwobble and I will get a nudge!

If you find my posts useful please consider donating something to a local charity or to the http://www.mndassociation.org/
B
64
S
34
G
47
Posts: 1,194
Reputation: 30,892

Post » Thu Nov 12, 2015 4:39 am

@gigatron, awesome work!

I've used your 2D starfield plugin before and was able to set an "Additive" effect value in the parameters to it in order to display a starfield 'over' a sprite.... HOWEVER, when using your 3D Star field, when I set the "Additive" effect value, I don't see the star field at all...

All I've done is created a sprite in the demo CAPX you provided, changed the 3D starfield object's "Effect" parameter to "Additive" and made sure that the Starfield has the highest z-order...

Any suggestions? Am I missing something? :)
B
74
S
14
G
1
Posts: 152
Reputation: 5,051

Post » Thu Nov 12, 2015 5:31 am

@remy-jay
I will fix this in a minute ..... Ok was done;
download plugin at the first post of this topic.

Have fun
B
69
S
24
G
29
Posts: 829
Reputation: 22,751

PreviousNext

Return to Completed Addons

Who is online

Users browsing this forum: No registered users and 2 guests