论坛交流
首页办公自动化| 网页制作| 平面设计| 动画制作| 数据库开发| 程序设计| 全部视频教程
应用视频: Windows | Word2007 | Excel2007 | PowerPoint2007 | Dreamweaver 8 | Fireworks 8 | Flash 8 | Photoshop cs | CorelDraw 12
编程视频: C语言视频教程 | HTML | Div+Css布局 | Javascript | Access数据库 | Asp | Sql Server数据库Asp.net  | Flash AS
当前位置 > 文字教程 > Flash教程
Tag:flash cs,flash 8,鼠绘,as,手绘,工具,文字,loading,入门,初学,mc,影片剪辑,声音,mtv,游戏,引导,遮罩,菜单,补间,广告条,时钟,视频教程

特別的爆破效果

文章类别:Flash | 发表日期:2008-9-21 19:20:29

   点击浏览该文件
http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash' type='application/x-shockwave-flash' width=480 height=360>http://www.flash8.net/bbs/UploadFile/2004-6/200461122484492.swf


看過了嗎... 那麼有沒有人發現這個爆炸的效果可以使用鼠標旋轉喔
以下是重要代碼部分.

//這裡的數學是根據需求自己重新定義的
Math.toDegrees = function (theta) {
return theta * 180 / Math.PI;
}


Math.toRadians = function (theta) {
return theta * Math.PI / 180;
}


Math.cosd = function (theta) {
return Math.cos(Math.toRadians(theta));
}


Math.sind = function (theta) {
return Math.sin(Math.toRadians(theta));
}


Particle3d = function (mcPath, initX, initY, initZ, velX, velY, velZ) {
this.graphic = eval(mcPath);
//3D空間中的位置...
this.x = initX;
this.y = initY;
this.z = initZ;
//根據指定座標的速率
this.vx = velX;
this.vy = velY;
this.vz = velZ;
//用來記錄"暫時"的旋轉座標
this.tx = this.x;
this.ty = this.y;
this.tz = this.z;


this.age = 0; //周期
this.dying = false;


this.graphic.init(); //初始MC
_parent.living.push(1);
}


Particle3d.prototype.live = function () {
this.move();
if (!clip) {
this.project();
this.render();
}
this.age++;
this.graphic.nextFrame();


if (this.age > this.lifespan && this.dying == false) {
this.kill();
}
}


Particle3d.prototype.move = function () {
this.vx += this.ax;
this.vy += this.ay;
this.vz += this.az;
this.vRot += this.aRot;


this.vx *= (1 - this.frictionX);
this.vy *= (1 - this.frictionY);
this.vz *= (1 - this.frictionZ);
this.vRot *= (1 - this.frictionRot);


//根據速率計算新的座標
this.x += this.vx;
this.y += this.vy;
this.z += this.vz;
this.rotation += this.vRot;
}


Point.prototype.rotateY = function (ry) {
//根據Y座標旋轉
this.cosRY = Math.cosd(ry);
this.sinRY = Math.sind(ry);


this.tx = this.x * this.cosRY + this.z * this.sinRY;
this.tz = this.x * -this.sinRY + this.z * this.cosRY;


this.x = this.tx;
this.z = this.tz;
}


Particle3d.prototype.project = function () {
//把3D座標顯示
//假如鼠標拖動就根據Y旋轉

if (this.rotating == true) {
//根據鼠標的位置計算出旋轉的角度
this.ry = _root.explosion.dragger._x;
//建立一個暫時的point來記錄旋轉
newP = new Point(this.x, this.y, this.z);
newP.rotateY(this.ry);
this.tx = newP.x;
this.ty = newP.y;
this.tz = newP.z;
delete (newP);
needRotation = true;


} else {
if (needRotation) { //當滑鼠放開時
//重新旋轉的座標有做下一次的旋轉
this.x = this.tx;
this.y = this.ty;
this.z = this.tz;


newP = new Point(this.vx, this.vy, this.vz);
newP.rotateY(this.ry);
this.vx = newP.x;
this.vy = newP.y;
this.vz = newP.z;
delete (newP);
needRotation = false;
this.ry = 0;
}
this.tx = this.x;
this.ty = this.y;
this.tz = this.z;
}


var d = 250; //鏡頭的角度
//mx, my, mz 可以旋轉全域的point
var mx = this.tx;
var my = this.ty;
var mz = this.tz + 45;
if (mz < 1) clip = true;
var pers = d / (1+mz); //計算perspective
this.sx = mx * pers;
this.sy = my * pers;


//根據距離感設定大小
this.scale = pers * 45;
}


Particle3d.prototype.render = function () {
this.graphic._x = this.sx;
this.graphic._y = -this.sy;
this.graphic._xscale = this.scale;
this.graphic._yscale = this.scale;
this.graphic._rotation = -this.rotation;
}


Particle3d.prototype.kill = function () {
this.graphic.kill();
this.dying = true;
}


Particle3d.prototype.toString = function () {
//用來除錯... :)
var output = "x=" + this.x;
output += " y=" + this.y;
output += " z=" + this.z;
output += " vx=" + this.vx;
output += " vy=" + this.vy;
output += " vz=" + this.vz;
output += " ax=" + this.ax;
output += " ay=" + this.ay;
output += " az=" + this.az;
output += " sx=" + this.sx;
output += " sy=" + this.sy;
return output;
}


function Point (inx, iny, inz) {
this.x = inx;
this.y = iny;
this.z = inz;
}


Movieclip.prototype.Point = _root.Point;
Movieclip.prototype.Particle3d = _root.Particle3d;




------------------------------------------------------------------------------
this.init();

function init() {
this.createParticles(this.maxParticles);
living = new Array();
this.dragging = false;
flare.play(); //閃光
}


function live() {
//當所有的particle的週期過了之後重新設定
if (this.living.length == 0) {
resetParticles(this.maxParticles);
}
}


function createParticles(num) {
for (var i=1; i<=num; i++) {
var pName = "p" + i;
duplicateMovieClip("path_streak", pName, i);
}
path_fragment._visible = false;
}


function resetParticles(num) {
for (var i=1; i<=num; i++) {
var pName = "p" + i;
this[pName].init();
}
flare.play();
}




------------------------------------------------------------------------------
this.init();

function init() {
iSpeed = 2.6;
iTheta = Math.random() * 360; //亂數取得角度
iPhi = Math.random() * 180;


initVelX = iSpeed * Math.cosd(iTheta) * Math.sind(iPhi);
initVelY = iSpeed * Math.sind(iTheta) * Math.sind(iPhi) + 1.5;
initVelZ = iSpeed * Math.cosd(iPhi);


p = new Particle3d("fragment", 0, 0, 0, initVelX, initVelY, initVelZ);

p.ax = p.az = 0;
p.ay = -.05;
//重力

p.vRot = 500 * (Math.random()-.5); //設定旋轉速度

p.frictionX = .09;
p.frictionY = .09;
p.frictionZ = .09;
p.frictionRot = .025;


p.lifespan = 50 + Math.floor(Math.random()*20);

}

function live() {
if (_parent.dragging == false) {
p.rotating = false;
p.live();
} else {
//當滑鼠拖動的時候停止播放和進行旋轉
p.rotating = true;
p.project();
p.render();
}
}


此文件建議新手還是建立好基礎再來研究...
点击浏览该文件


上一篇:{应用}水珠滑落效果 人气:2327
下一篇:{应用}构建随机运动的效果 人气:2187
视频教程列表
文章教程搜索
 
Flash推荐教程
Flash热门教程
看全部视频教程
购买方式/价格
购买视频教程: 咨询客服
tel:15972130058