Dec 24, 2009
lot of time without posting some code. I have been working three months on a Disney project, which will be on-line soon and makes me very proud, but almost drained all of my energies.
Here is my Christmas card/gift for my readers, in less than 80 lines of code. Obviously with source code. The lights are vector graphics in the attached FLA’s library to make it easy to customize or animate.
Nothing too fancy here about the code, just some trigonometric math. You can have a look at the correctOrientations function which can be interesting to avoid lights deformations due to the FP10 native 3D.
Download source code.
I wish you all great winter holidays, and an awesome beginning of 2010!
And make me smile by leaving a greetings comment
Watch the running example:
Click to start (mouseX affects rotation)
Oct 8, 2008
I don’t usually post about two lines of code snippets, or about workarounds to that damn bug or about basic tutorials for beginners. I honestly haven’t enough time and will to post on a daily basis. Usually I use this blog to mantain me focused on a single project I find interesting and take it to the end (not a really working however ).
Logic comes first, code is the last step
So what about the title? What’s the the perfect beginner but somehow satisfying tutorial?
Answer snow/rain/starfield and you got it, and here we have a basic starfield class tutorial.
However the main reason I am posting this is not about the 30-40 code lines involved in rendering a random starfield but make you stop a moment and think about a possible easier way to do what you are doing.
I’ll try to be clearer: this morning I was working on a flash animation and just wanted to place a background starfield on my bucholic landscape view. So I quickly created the class but was missing something… off course a starfield is not cool if stars don’t twinkle (winkle, scintillate
shine… vary in light intensity etc.). So I started to recall the milions of experiments like this I did years ago in Actionscript 1 and ok… the first answer was something like:
- Generate every star as a sprite/movieclip (possibily in a main container)
- list the instance in some array, dictionary (whatever you prefer)
- to make ‘em twinkle, at every frame, do a for loop on every instance and vary its alpha with some some increment/decrement/sine calculation (o simply randomize it if you are lazy)
or you can have a Star class togheter with the Starfield class and let the Star class think about everything, so it creates its EnterFrame event to start twinkling when added (but it’s always a bad idea to have hundres of EnterFrame events, when you can have only one in the main class.
Flash teach me that there are always many options to get to the same results (that is what I really like most about flash developing), AND… that bitmap filters and blend modes are a gift to hardcore developers with tremendous possibilities.
So.. do we really want a subtle background effect to keep 50% of the CPU? I don’t.
Continue Reading »
Sep 27, 2008
Updated on 04/27/2009: Class with some improvements to skip transparent pixels. The two images should however share the same amount (or similar) of visible pixels.
Lot of space for improvements here, if someone want to contribute very appreciated.
Ok, lot of time passed since I posted my PixelMorphing class experiment.
Seemed to me that post passed quite unobserved but then I received a lot of feedback and e-mail asking to share the source code.
Well, the first time I wanted to speed up posting and do further experimentation/optimization so I din’t prepare the source but since the main believe of this blog is that if someone ask for code I release it, here we are. Optimization still not done… I am a lazy one, so if someone want to help improve it is really welcome.
Now the steps to play with it:
- Download the PixelMorphing class
- Use it with this code:
var pm:PixelMorphing=new PixelMorphing(pic1, pic2, 200);
or certainly you can place some buttons or some combo and wait for some event for it to start or reset. The main code of the previous post is this:
Continue Reading »
Apr 2, 2008
Hi there, some time since I last posted a technical post so here we are.
I was experimenting with some simple 3d formulas and this is the result…
1200 particles morphing in 3D space.
Added an interactive camera to start having fun.
Simply move your mouse up/down to move camera forward/backward and left/right for strafing.
Perss SPACE bar to cycle particle conformation between four different shapes.
For better experience move forward and backward while particles are morphing…
Following the morph from behind while moving very fast feel very gratifing for me
On my old CPU it performs @31fps and neither takes the cpu at 100%
No z-sorting here, just fun. I am not trying to build a real 3d engine… and no class for now, just some procedural code, but I am sure my cool readers will not have problems wrapping it inside a class definition if needed. Also this site’s loading time is quite slow lately, to enhance it I might move into small business hosting in the future.
Caurina Tweener needed.
Experience the demo
And here come the code! Simply past it in the first frame actions of a new fla.
Continue Reading »
Feb 24, 2008
I just edited the Fountain equalizer post adding the source code.
You’ll just need to download the two particles classes and copy the main code.
I received really a lot of requests about the code in the comments and by mail, and I am very pleased about this… means you liked it.
Expect more equalizing fun.