THE ACTIONSCRIPT IS IN THE COMMENTS! LOOK FOR THE AS BELOW!
Yay 4th MiniTut in the series! Well, this time it's all about swarming, hope you enjoy. The only drawback is, we couldn't fit the AS into the movie, so we had to put it in here. It's only one frame, hence the name "MiniTut" (short for miniature tuturial) so please do not leave pissy reviews.
***Please review!***
ACTION SCRIPT FOR SWARMING:
fly = function () {
this.animate = function() {
this.targetX = _root._xmouse;
this.targetY = _root._ymouse;
this.distX = this.targetX-this.meX+thi s.flockX;
this.distY = this.targetY-this.meY+thi s.flockY;
if ((this.targetX == this.oldTargetX) && Math.random()>0.9) {
this.flockX = (Math.random()*100)-50;
this.flockY = (Math.random()*100)-50;
} else if ((this.targetX<>this.oldT argetX) && Math.random()>0.8) {
this.flockX = (Math.random()*400)-200;
this.flockY = (Math.random()*400)-200;
}
this.meX = Math.round(this.meX+(this .distX)/20);
this.meY = Math.round(this.meY+(this .distY)/20);
this._x = this.meX;
this._y = this.meY;
this.oldTargetX = this.targetX;
};
this.initialize = function() {
this.targetX = 0;
this.targetY = 0;
this.distX = 0;
this.distY = 0;
this.meX = this._x;
this.meY = this._y;
this.oldTargetX = 0;
this.flockX = (Math.random()*200)-100;
this.flockY = (Math.random()*200)-100;
};
this.initialize();
this.onEnterFrame = this.animate;
};
var i:Number = 0;
var bugClip:MovieClip;
for (i=0; i<30; i++) {
bugClip = this.attachMovie("bug", "bug"+i, i);
fly.apply(bugClip);
}
- - -
These are rather simple script components, but don't underestimate them. They are rather hard to individually explain, so I'd reccommend asking someone like Luther or S-S-X for explanations. I personally did not get the code, my teammate S-E-R07 (Soul-Eating-Reaper07) did, so i guess you could ask him...
- - -
Credits:
Andrea364: instructions, flashing it out
Haley87: Layout, inspiration, etc.
Soul-Eating-Reaper07: ActionScript.
- - -
Comments-
Andrea364: I'm happy with this work, since it should help people in need of such script and instructions. I'll definitely have room to be proud of it in the long run when I eventually update it.
Haley87: Well, it's done, and in less than a day too! I wonder what our next project will be? Look forward to something on Clock Day!
Soul-Eating-Reaper07: -no comment-
- - -
Well, Enjoy!