View Full Version : Which approach? Swap layers...
scooterbabe
11-17-2005, 02:25 PM
Ciao!
In my current e-learning project I'm creating a solar system, with the planets orbiting the sun in a "3D" fashion. When the planets are passing in front of the sun, pluto is of course the top most layer, and also if a planet is between pluto and the sun, in line with the viewer, Pluto will make all of or a part of that planet hidden.
The same goes for all the planets that are on an outer path than an other planet, when passing in front of the sun.
But when being on the half of the orbit-ellipse that is behind the sun, the layer stacking should be different.
And this is where I need the input - which is the most intelligent way to achieve this effect?
Also note that the planets orbits with different time intervals, so that in the time pluto makes one lap, the sun makes a hundred or something ;)
Ruben
11-17-2005, 07:13 PM
I'd use .swapDepths() (http://www.macromedia.com/support/flash/action_scripts/actionscript_dictionary/actionscript_dictionary571.html), here's a great tutorial on that subject:
http://www.actionscript.org/tutorials/intermediate/swap_depths/index.shtml
:) - Ruben
scooterbabe
11-18-2005, 11:33 AM
Hello!
Yes, I'm familiar with this function, but it's a bit more complicated since I it's not enough to just swap 2 planets - mercurius could be in front of the sun and pluto behind, f ex, so actually I think I need to create some kind of stack - one for the planets that currently is in front of the sun and one for the planets behind...?
Ruben
11-18-2005, 01:43 PM
Hmm, this might get pretty complicated. I guess it's up to you to decide what you're gonna do, since I don't really know about how well you're handling the actionscript-bit.
Using .swapDepths() (http://www.macromedia.com/support/flash/action_scripts/actionscript_dictionary/actionscript_dictionary571.html) would most likely require using arrays (http://www.actionscript.org/tutorials/intermediate/Arrays/index.shtml) to store the z-order of all the planets, functions for reordering the planets and scripted loops (http://www.actionscript.org/tutorials/intermediate/loops/index.shtml) to browse through all the values of the arrays.
It would also come in handy to use actionscripted motion (http://www.actionscript.org/tutorials/intermediate/Motion_using_Actionscript/index.shtml) involving trigonometry (http://www.actionscript.org/tutorials/advanced/trigonometry_and_flash/index.shtml) for having the planets circle around eachother, but this is not a must.
Fortunately there's an alternative. If there's no transparency involved (as in gradient glows around the planets) then you could work with masks masking the planets that are going 'around the back'.
For example; If you'd have planet earth circling around the sun and at a certain point earth's at the backside of the sun, at the frame before earth is being 'hidden' by the sun you would place a masking movieclip (.attachMovie() (http://www.macromedia.com/support/flash/action_scripts/actionscript_dictionary/actionscript_dictionary508.html)) on the same level (this movieclip should be something like a big square with in the middle a circle cut out), you adjust the size of the masking movieclip so that the cut out circle will be of the same size as the sun. Finally you will have it masking earth using .setMask() (http://www.macromedia.com/support/flash/action_scripts/actionscript_dictionary/actionscript_dictionary566.html).
And I think that's about it...
:) - Ruben
|
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.