Flash AS 制作生化危機(jī)游戲的簡(jiǎn)單嘗試_Flash教程
推薦:Flash簡(jiǎn)單實(shí)現(xiàn)網(wǎng)頁(yè)中的Flash動(dòng)畫(huà)全屏Flash播放器自從升級(jí)到FlashPlayer9,0,28,0,也可以使網(wǎng)頁(yè)中的Flash通過(guò)一個(gè)簡(jiǎn)單的按鈕實(shí)現(xiàn)全屏顯示,和一些視頻網(wǎng)站中的效果基本相同,但是在這個(gè)教程里是沒(méi)
這個(gè)教程先給大家做一個(gè)游戲中的場(chǎng)景,只是簡(jiǎn)單的嘗試著做做!
友情提醒:由于該教程中演示Flash動(dòng)畫(huà)較多,所以打開(kāi)本頁(yè)后速度會(huì)慢些甚至影響瀏覽器!請(qǐng)關(guān)閉其它所有程序嘗試!在教程的最后提供了所有演示的Fla源文件。
首先布置地圖,并且做一個(gè)角色。



做好了上面的就可以了!下面我們開(kāi)始添加代碼�;氐降谝粠砑尤缦麓a。
walk_speed = 3;
radius = 8;
_root.attachMovie("ground", "ground", _root.getNextHighestDepth());
_root.attachMovie("environment", "environment", _root.getNextHighestDepth());
_root.attachMovie("player", "player", _root.getNextHighestDepth(), {_x:250, _y:200});
_root.createEmptyMovieClip("light", _root.getNextHighestDepth());
player.onEnterFrame = function() {
if (Key.isDown(Key.LEFT)) {
this._x -= walk_speed;
}
if (Key.isDown(Key.RIGHT)) {
this._x = walk_speed;
}
if (Key.isDown(Key.UP)) {
this._y -= walk_speed;
}
if (Key.isDown(Key.DOWN)) {
this._y = walk_speed;
}
while (_root.environment.hitTest(this._x, this._y radius, true)) {
this._y--;
}
while (_root.environment.hitTest(this._x, this._y-radius, true)) {
this._y ;
}
while (_root.environment.hitTest(this._x-radius, this._y, true)) {
this._x ;
}
while (_root.environment.hitTest(this._x radius, this._y, true)) {
this._x--;
}
dist_x = this._x-_root._xmouse;
dist_y = this._y-_root._ymouse;
angle = -Math.atan2(dist_x, dist_y);
this._rotation = angle/(Math.PI/180);
};
測(cè)試效果,這時(shí)有地圖和角色了。
我們?cè)倮^續(xù)修改代碼。
torch_power = 100;
torch_step = 100;
torch_angle = 60;
torch_angle_step = 20;
walk_speed = 3;
radius = 8;
_root.attachMovie("ground", "ground", _root.getNextHighestDepth());
_root.attachMovie("environment", "environment", _root.getNextHighestDepth());
_root.attachMovie("player", "player", _root.getNextHighestDepth(), {_x:250, _y:200});
_root.createEmptyMovieClip("light", _root.getNextHighestDepth());
player.onEnterFrame = function() {
if (Key.isDown(Key.LEFT)) {
this._x -= walk_speed;
}
if (Key.isDown(Key.RIGHT)) {
this._x = walk_speed;
}
if (Key.isDown(Key.UP)) {
this._y -= walk_speed;
}
if (Key.isDown(Key.DOWN)) {
this._y = walk_speed;
}
while (_root.environment.hitTest(this._x, this._y radius, true)) {
this._y--;
}
while (_root.environment.hitTest(this._x, this._y-radius, true)) {
this._y ;
}
while (_root.environment.hitTest(this._x-radius, this._y, true)) {
this._x ;
}
while (_root.environment.hitTest(this._x radius, this._y, true)) {
this._x--;
}
dist_x = this._x-_root._xmouse;
dist_y = this._y-_root._ymouse;
angle = -Math.atan2(dist_x, dist_y);
this._rotation = angle/(Math.PI/180);
light.clear();
light.lineStyle(1, 0xffffff);
for (x=0; x<=torch_angle; x = (torch_angle/torch_angle_step)) {
light.moveTo(this._x, this._y);
ray_angle = angle/(Math.PI/180)-90-(torch_angle/2) x;
ray_angle = ray_angle*(Math.PI/180);
light.lineTo(this._x (torch_power)*Math.cos(ray_angle), this._y (torch_power)*Math.sin(ray_angle));
light.lineTo(this._x, this._y);
}
};
效果如下。
我們?cè)倮^續(xù)修改代碼。
torch_power = 100;
torch_step = 100;
torch_angle = 60;
torch_angle_step = 20;
walk_speed = 3;
radius = 8;
_root.attachMovie("ground", "ground", _root.getNextHighestDepth());
_root.attachMovie("environment", "environment", _root.getNextHighestDepth());
_root.attachMovie("player", "player", _root.getNextHighestDepth(), {_x:250, _y:200});
_root.createEmptyMovieClip("light", _root.getNextHighestDepth());
player.onEnterFrame = function() {
if (Key.isDown(Key.LEFT)) {
this._x -= walk_speed;
}
if (Key.isDown(Key.RIGHT)) {
this._x = walk_speed;
}
if (Key.isDown(Key.UP)) {
this._y -= walk_speed;
}
if (Key.isDown(Key.DOWN)) {
this._y = walk_speed;
}
while (_root.environment.hitTest(this._x, this._y radius, true)) {
this._y--;
}
while (_root.environment.hitTest(this._x, this._y-radius, true)) {
this._y ;
}
while (_root.environment.hitTest(this._x-radius, this._y, true)) {
this._x ;
}
while (_root.environment.hitTest(this._x radius, this._y, true)) {
this._x--;
}
dist_x = this._x-_root._xmouse;
dist_y = this._y-_root._ymouse;
angle = -Math.atan2(dist_x, dist_y);
this._rotation = angle/(Math.PI/180);
light.clear();
light.lineStyle(1, 0xffffff);
for (x=0; x<=torch_angle; x = (torch_angle/torch_angle_step)) {
light.moveTo(this._x, this._y);
ray_angle = angle/(Math.PI/180)-90-(torch_angle/2) x;
ray_angle = ray_angle*(Math.PI/180);
for (y=1; y<=torch_step; y ) {
if (environment.hitTest(this._x (torch_power/torch_step*y)*Math.cos(ray_angle), this._y (torch_power/torch_step*y)*Math.sin(ray_angle), true)) {
break;
}
}
light.lineTo(this._x (torch_power/torch_step*y)*Math.cos(ray_angle), this._y (torch_power/torch_step*y)*Math.sin(ray_angle));
}
};
效果如下。
我們?cè)倮^續(xù)修改代碼。
torch_power = 100;
torch_step = 100;
torch_angle = 60;
torch_angle_step = 20;
walk_speed = 3;
radius = 8;
_root.attachMovie("ground", "ground", _root.getNextHighestDepth());
_root.attachMovie("environment", "environment", _root.getNextHighestDepth());
_root.attachMovie("player", "player", _root.getNextHighestDepth(), {_x:250, _y:200});
_root.createEmptyMovieClip("light", _root.getNextHighestDepth());
player.onEnterFrame = function() {
if (Key.isDown(Key.LEFT)) {
this._x -= walk_speed;
}
if (Key.isDown(Key.RIGHT)) {
this._x = walk_speed;
}
if (Key.isDown(Key.UP)) {
this._y -= walk_speed;
}
if (Key.isDown(Key.DOWN)) {
this._y = walk_speed;
}
while (_root.environment.hitTest(this._x, this._y radius, true)) {
this._y--;
}
while (_root.environment.hitTest(this._x, this._y-radius, true)) {
this._y ;
}
while (_root.environment.hitTest(this._x-radius, this._y, true)) {
this._x ;
}
while (_root.environment.hitTest(this._x radius, this._y, true)) {
this._x--;
}
dist_x = this._x-_root._xmouse;
dist_y = this._y-_root._ymouse;
angle = -Math.atan2(dist_x, dist_y);
this._rotation = angle/(Math.PI/180);
light.clear();
light.lineStyle(1, 0xffffff);
light.moveTo(this._x, this._y);
for (x=0; x<=torch_angle; x = (torch_angle/torch_angle_step)) {
ray_angle = angle/(Math.PI/180)-90-(torch_angle/2) x;
ray_angle = ray_angle*(Math.PI/180);
for (y=1; y<=torch_step; y ) {
if (environment.hitTest(this._x (torch_power/torch_step*y)*Math.cos(ray_angle), this._y (torch_power/torch_step*y)*Math.sin(ray_angle), true)) {
break;
}
}
light.lineTo(this._x (torch_power/torch_step*y)*Math.cos(ray_angle), this._y (torch_power/torch_step*y)*Math.sin(ray_angle));
}
light.lineTo(this._x, this._y);
};
效果如下。
我們?cè)倮^續(xù)修改代碼。
torch_power = 100;
torch_step = 100;
torch_angle = 60;
torch_angle_step = 20;
walk_speed = 3;
radius = 8;
_root.attachMovie("ground", "ground", _root.getNextHighestDepth());
_root.attachMovie("environment", "environment", _root.getNextHighestDepth());
_root.attachMovie("player", "player", _root.getNextHighestDepth(), {_x:250, _y:200});
_root.createEmptyMovieClip("light", _root.getNextHighestDepth());
player.onEnterFrame = function() {
if (Key.isDown(Key.LEFT)) {
this._x -= walk_speed;
}
if (Key.isDown(Key.RIGHT)) {
this._x = walk_speed;
}
if (Key.isDown(Key.UP)) {
this._y -= walk_speed;
}
if (Key.isDown(Key.DOWN)) {
this._y = walk_speed;
}
while (_root.environment.hitTest(this._x, this._y radius, true)) {
this._y--;
}
while (_root.environment.hitTest(this._x, this._y-radius, true)) {
this._y ;
}
while (_root.environment.hitTest(this._x-radius, this._y, true)) {
this._x ;
}
while (_root.environment.hitTest(this._x radius, this._y, true)) {
this._x--;
}
dist_x = this._x-_root._xmouse;
dist_y = this._y-_root._ymouse;
angle = -Math.atan2(dist_x, dist_y);
this._rotation = angle/(Math.PI/180);
light.clear();
light.beginFill(0xffffff, 100);
light.lineStyle(1, 0xffffff);
light.moveTo(this._x, this._y);
for (x=0; x<=torch_angle; x = (torch_angle/torch_angle_step)) {
ray_angle = angle/(Math.PI/180)-90-(torch_angle/2) x;
ray_angle = ray_angle*(Math.PI/180);
for (y=1; y<=torch_step; y ) {
if (environment.hitTest(this._x (torch_power/torch_step*y)*Math.cos(ray_angle), this._y (torch_power/torch_step*y)*Math.sin(ray_angle), true)) {
break;
}
}
light.lineTo(this._x (torch_power/torch_step*y)*Math.cos(ray_angle), this._y (torch_power/torch_step*y)*Math.sin(ray_angle));
}
light.lineTo(this._x, this._y);
light.endFill();
ground.setMask(light);
};
效果如下。
好了!今天先講到這里。最后給大家提供上面所有演示的源文件。點(diǎn)擊這里下載Fla源文件(431K自行查殺病毒)
分享:Flash教程:用AS實(shí)現(xiàn)右鍵菜單的最簡(jiǎn)單方法非常簡(jiǎn)單的代碼,把下面代碼直接放到新建立的Flash的第一幀varlinkURL=http://m.hl5o.cn;varlinkText=連接到我的網(wǎng)站;//定義一個(gè)新的右鍵菜單項(xiàng)
- as中禁用ESC鍵
- AS3.0 圖片變黑白 圖片彩色變黑白代碼
- flash as3.0 跨域的解決辦法
- 模板無(wú)憂FLASH透明代碼
- Flash教你制作卡通MM眨眼睛動(dòng)畫(huà)
- Flash從零開(kāi)始學(xué)習(xí)創(chuàng)建單選按鈕
- Flash繪制小龍與花插畫(huà)場(chǎng)景
- Flash程序的測(cè)試方法
- Flash CS4文字顏色緩動(dòng)特效
- 網(wǎng)頁(yè)中演示類(lèi)FLASH動(dòng)畫(huà)制作規(guī)范
- Flash CS3循環(huán)背景的運(yùn)用技巧
- Flash鼠繪技巧教你制作紅綠色的樹(shù)葉
Flash教程Rss訂閱網(wǎng)站制作教程搜索
Flash教程推薦
猜你也喜歡看這些
- 中科院新科海Flash培訓(xùn)視頻
- Flash CS3動(dòng)畫(huà)制作從新手到高手
- 臺(tái)灣呂聰賢Flash MX視頻教程
- flash運(yùn)動(dòng)規(guī)律與動(dòng)作實(shí)現(xiàn)
- 課件\flash的多媒體教程
- flash動(dòng)作編程教程
- Flash卡通動(dòng)畫(huà)設(shè)計(jì)-隨書(shū)光盤(pán)
- FIF小組FLASH MX 2004實(shí)例視頻教程
- Flash CS3動(dòng)畫(huà)設(shè)計(jì)入門(mén)提高與技巧(光盤(pán)).
- 中文版Flash CS4標(biāo)準(zhǔn)教程
- 相關(guān)鏈接:
- 教程說(shuō)明:
Flash教程-Flash AS 制作生化危機(jī)游戲的簡(jiǎn)單嘗試
。