Flash动画制作贪吃蛇游戏.ppt

上传人:xt****7 文档编号:17039062 上传时间:2020-11-07 格式:PPT 页数:19 大小:589KB
返回 下载 相关 举报
Flash动画制作贪吃蛇游戏.ppt_第1页
第1页 / 共19页
Flash动画制作贪吃蛇游戏.ppt_第2页
第2页 / 共19页
Flash动画制作贪吃蛇游戏.ppt_第3页
第3页 / 共19页
点击查看更多>>
资源描述
贪吃蛇游戏 一、作品展示及分析: 贪吃蛇游戏 二、游戏制作步骤: 1.新建文档, 600*410,背景色为 #0066CC。 2.在图层 1“背景”上绘制一个 400*400的黑色矩形,再绘制一个 160*385的黑 色矩形,调整成平行四边形。在第 8帧插入普通帧。 3. 新建图“蓝色矩形”,绘制一个 400*400的矩形,颜色 #66ccff,插入点: 0, 0。放置在黑色矩形上,形成阴影效果。也可直接复制,修改颜色后形成阴影 效果。同理,绘制一个平行四边形形成阴影效果。 贪吃蛇游戏 4.新建元件 food,在第 1帧输入脚本代码: stop();第 2帧绘制 一个苹果,调整尺寸大小为 13.8*15.2 5.新建元件 worm,绘制一个直径为 16的绿色放射状圆形, 插入点为( -8, -8)。再绘制两条直线做为触角。 6。新建元件 worm_tail,直径为 16,放射状灰色,插入点为 ( -8, -8)。 贪吃蛇游戏 7.新建按钮元件 new_game如下: 8.新建图层”小格子“ :在蓝色矩形上绘制 16*16的小格子 ,白色,线宽 1。复制 更多的小格子,摆放整齐。每行 25个,共 25行。 贪吃蛇游戏 9.新建图层“右面板”,输入静态文本“ Worm!”及“ Use the arrow keys to comtrol the snake”,拖入 arrow 和 apple元件。最后创建动 态文本框。变量名为 eaten。拖入 New Game按钮,添加动作脚本: on (release) gotoAndPlay(initialize); 贪吃蛇游戏 10.新建图层”蛇和苹果” ,在第 3帧插入空白关键帧 ,拖入 worm、 worm_tail、 food元件。实例名称分别为: worm、 tail1、 tail2、 food。在第 6帧插入空白关键帧,输入静态 文本: Game Over! 贪吃蛇游戏 11.新建图层“标签”,在第 2帧插入空白关键帧,输入标签名: initialize;在第 3帧插入空白关键帧,输入标签名: game loop;在第 6帧插入空白关键帧,输入标签名: game over。 12.新建图层”动作” ,在第 1帖输入动作代码 :stop(); 在第 2帧输入动作代码 : mleft = 1; mright = 0; mup = 0; mdown = 0; food = 0; tails = 2; eaten = 0; time = 0; 贪吃蛇游戏 在第 3帧输入动作代码 : dead = 0; if (!food) randomy = 16 * (random(25); randomx = 16 * (random(25); setProperty(/food, _x, (randomx + 8); setProperty(/food, _y, (randomy + 8); food = 1; tellTarget(/food) gotoAndStop(2); 贪吃蛇游戏 if (mleft) if (getProperty(/worm, _x) = 8) lastx = getProperty(/worm, _x); lasty = getProperty(/worm, _y); setProperty(/worm, _x, (getProperty(/worm, _x) - 16); setProperty(/worm, _rotation, 0); else dead = 1; else if (mright) if (getProperty(/worm, _x) = 8) lastx = getProperty(/worm, _x); lasty = getProperty(/worm, _y); setProperty(/worm, _y, (getProperty(/worm, _y) - 16); setProperty(/worm, _rotation, 90); else dead = 1; else if (mdown) if (getProperty(/worm, _y) = 392) lastx = getProperty(/worm, _x); lasty = getProperty(/worm, _y); setProperty(/worm, _y, (getProperty(/worm, _y) + 16); setProperty(/worm, _rotation, 270); else dead = 1; 贪吃蛇游戏 for(currenttail = 1;currenttail = tails;currenttail+) usex = lastx; usey = lasty; lastx = getProperty(/tailadd currenttail, _x); lasty = getProperty(/tailadd currenttail, _y); setProperty(/tailadd currenttail, _x, usex); setProperty(/tailadd currenttail, _y, usey); fcurrentx = getProperty(/food, _x); fcurrenty = getProperty(/food, _y); wcurrentx = getProperty(/worm, _x); wcurrenty = getProperty(/worm, _y); if (wcurrentx = fcurrentx tellTarget(/food) gotoAndStop(1); eaten += 1; 贪吃蛇游戏 if (eaten % 2 = 0) _root.tail1.duplicateMovieClip( tail + (tails+1), tails+1); setProperty(/tailadd tails, _x, usex); setProperty(/tailadd tails, _y, usey); tails += 1; if (!dead) for(currenttail = 1;currenttail = tails;currenttail+) if (getProperty(/worm, _x) = getProperty(/tailadd currenttail, _x) if (getProperty(/worm, _y) = getProperty(/tailadd currenttail, _y) dead = 1; break; if (dead) gotoAndPlay(game over); 贪吃蛇游戏 在第 4帧输入动作代码 :gotoAndPlay(game loop); 在第 6帧输入动作代码 : for(currenttail = 3;currenttail = tails;currenttail+) setProperty(/tail add currenttail, _visible, false); 在第 7帧插入动作代码 :stop(); 贪吃蛇游戏 13最后 ,为 worm影片添加动作脚本: onClipEvent ( keyDown ) if (Key.isDown( Key.LEFT) if (!./:mright) ./:mleft = 1; ./:mright = 0; ./:mup = 0; ./:mdown = 0; if (Key.isDown( Key.RIGHT) if (!./:mleft) ./:mleft = 0; ./:mright = 1; ./:mup = 0; ./:mdown = 0; 贪吃蛇游戏 if (Key.isDown( Key.UP) if (!./:mdown) ./:mleft = 0; ./:mright = 0; ./:mup = 1; ./:mdown = 0; if (Key.isDown( Key.DOWN) if (!./:mup) ./:mleft = 0; ./:mright = 0; ./:mup = 0; ./:mdown = 1; 贪吃蛇游戏 14为 worm影片添加动作脚本: onClipEvent ( keyDown ) if (Key.isDown( Key.LEFT) if (!./:mright) ./:mleft = 1; ./:mright = 0; ./:mup = 0; ./:mdown = 0; if (Key.isDown( Key.RIGHT) if (!./:mleft) ./:mleft = 0; ./:mright = 1; ./:mup = 0; ./:mdown = 0; 贪吃蛇游戏 if (Key.isDown( Key.UP) if (!./:mdown) ./:mleft = 0; ./:mright = 0; ./:mup = 1; ./:mdown = 0; if (Key.isDown( Key.DOWN) if (!./:mup) ./:mleft = 0; ./:mright = 0; ./:mup = 0; ./:mdown = 1; 贪吃蛇游戏 注意: 1、在拖入 worm元件时,一定要将其放在 16*N+8的位置上,否则就不能跟 food的坐 标保持一致的话就不能吃到苹果了。 2、修改发布设置: flash 5,版本为 1.0
展开阅读全文
相关资源
相关搜索

最新文档


当前位置:首页 > 图纸专区 > 课件教案


copyright@ 2023-2025  zhuangpeitu.com 装配图网版权所有   联系电话:18123376007

备案号:ICP2024067431-1 川公网安备51140202000466号


本站为文档C2C交易模式,即用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。装配图网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知装配图网,我们立即给予删除!