论坛交流
首页办公自动化| 网页制作| 平面设计| 动画制作| 数据库开发| 程序设计| 全部视频教程
应用视频: 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 20:13:04

   点击浏览该文件
点击浏览该文件
http://bbs.flash8.net/bbs/UploadFile/2005-7/200573191420452.swf
首先:将背景改成大小300X301
按此在新窗口浏览图片
划一个坦克的外形:
按此在新窗口浏览图片
将它选中按F8变成影片剪辑。
再新建一个影片剪辑第一帧是空白帧;代码:


stop();

第二帧是这样的:
按此在新窗口浏览图片
新建一个影片剪辑,将两个东东从库里拖出来:
按此在新窗口浏览图片
那个小点点是开炮用的,将它命名huo。
到了最要害的地方了,也是代码最长的地方。将刚做的MC拖入场景,输入代码:
onClipEvent (load) {
Speed = 5;
}
onClipEvent (enterFrame) {
if (Key.isDown(Key.LEFT) and !Key.isDown(Key.RIGHT)) {
_x -= Speed;
_rotation = 270;
}
if (Key.isDown(Key.RIGHT) and !Key.isDown(Key.LEFT)) {
_x += Speed;
_rotation = 90;
}
if (Key.isDown(Key.UP) and !Key.isDown(Key.DOWN)) {
_y -= Speed;
_rotation = 0;
}
if (Key.isDown(Key.DOWN) and !Key.isDown(Key.UP)) {
_y += Speed;
_rotation = 180;
}
if (Key.isDown(Key.LEFT) and Key.isDown(Key.UP) and !Key.isDown(Key.RIGHT) and !Key.isDown(Key.DOWN)) {
_rotation = 315;
}
if (Key.isDown(Key.RIGHT) and Key.isDown(Key.UP) and !Key.isDown(Key.LEFT) and !Key.isDown(Key.DOWN)) {
_rotation = 45;
}
if (Key.isDown(Key.LEFT) and Key.isDown(Key.DOWN) and !Key.isDown(Key.RIGHT) and !Key.isDown(Key.UP)) {
_rotation = 225;
}
if (Key.isDown(Key.RIGHT) and Key.isDown(Key.DOWN) and !Key.isDown(Key.LEFT) and !Key.isDown(Key.UP)) {
_rotation = 135;
}
if (_x<-5) {
_x = 301;
}
if (_x>306) {
_x = 0;
}
if (_y>305) {
_y = 0;
}
if (_y<-5) {
_y = 300;
}
if (Key.isDown(Key.SPACE)) {
with (huo) {
gotoAndPlay(2);
}
}
}

别怕怕,这么长的代码很简单。下面是注释过的代码:

onClipEvent (load) {
Speed = 5;
//始初话Speed(本来想用Sp,一想是骂人,哈哈)
}
onClipEvent (enterFrame) {
if (Key.isDown(Key.LEFT) and !Key.isDown(Key.RIGHT))//避免错误 {
_x -= Speed;
_rotation = 270;
}
if (Key.isDown(Key.RIGHT) and !Key.isDown(Key.LEFT)) //避免错误{
_x += Speed;
_rotation = 90;
}
if (Key.isDown(Key.UP) and !Key.isDown(Key.DOWN)) //避免错误{
_y -= Speed;
_rotation = 0;
}
if (Key.isDown(Key.DOWN) and !Key.isDown(Key.UP)) //避免错误{
_y += Speed;
_rotation = 180;
}
//下为设置_rotation的代码,只需复制更改一下即可
if (Key.isDown(Key.LEFT) and Key.isDown(Key.UP) and !Key.isDown(Key.RIGHT) and !Key.isDown(Key.DOWN)) {
_rotation = 315;
}
if (Key.isDown(Key.RIGHT) and Key.isDown(Key.UP) and !Key.isDown(Key.LEFT) and !Key.isDown(Key.DOWN)) {
_rotation = 45;
}
if (Key.isDown(Key.LEFT) and Key.isDown(Key.DOWN) and !Key.isDown(Key.RIGHT) and !Key.isDown(Key.UP)) {
_rotation = 225;
}
if (Key.isDown(Key.RIGHT) and Key.isDown(Key.DOWN) and !Key.isDown(Key.LEFT) and !Key.isDown(Key.UP)) {
_rotation = 135;
}
//一下为转圈代码,为什么要加5呢,因为这5可以使其更自然一点
if (_x<-5) {
_x = 301;
}
if (_x>306) {
_x = 0;
}
if (_y>305) {
_y = 0;
}
if (_y<-5) {
_y = 300;
}
//一下为开火,所以我刚才教你们做火
if (Key.isDown(Key.SPACE)) {
with (huo) {
gotoAndPlay(2);
}
}
}

嗯,主要搞完了,美化一下:
按此在新窗口浏览图片
上一篇:{教程}清新又不失闪炫的流程图 人气:1054
下一篇:{教程}颜色渐变效果 人气:2043
视频教程列表
文章教程搜索
 
Flash推荐教程
Flash热门教程
看全部视频教程
购买方式/价格
购买视频教程: 咨询客服
tel:15972130058