用纯Flash Actionscript做的火柴棍小人跑的动画 程序员文章站 2022-03-20 10:40:50 非常有趣,本教程描绘的是完全用ActionScript做的一个火柴棍小人跑步的动画,你相信吗?完全是AS实现的。 先看效果吧 做的方法非常简单,直接把下面代码复制到第一帧,最好... 08-10-06... 非常有趣,本教程描绘的是完全用actionscript做的一个火柴棍小人跑步的动画,你相信吗?完全是as实现的。 先看效果吧 做的方法非常简单,直接把下面代码复制到第一帧,最好把帧频调到18fps。 以下为引用的内容: fscommand("allowscale", false);fscommand("showmenu", false); linestyle(1, 0x000000, 100);moveto(0, 135);lineto(550, 135);moveto(0, 185);lineto(550, 185);linestyle(2, 0x000000, 100);moveto(26, 16);lineto(37, 16);lineto(37, 39);curveto(28, 43, 33, 67);moveto(37, 16);lineto(26, 24);moveto(37, 24);lineto(26, 31);moveto(37, 32);lineto(26, 40);moveto(41, 15);lineto(53, 14);lineto(53, 39);curveto(39, 45, 50, 66);moveto(53, 14);lineto(42, 21);moveto(53, 23);lineto(42, 28);moveto(53, 31);lineto(42, 38);moveto(27, 75);lineto(27, 90);lineto(39, 92);moveto(33, 74);lineto(33, 91);moveto(38, 74);lineto(38, 83);lineto(33, 84);moveto(33, 95);curveto(41, 113, 48, 94);moveto(41, 94);lineto(41, 127);moveto(30, 124);curveto(38, 84, 51, 125);moveto(55, 75);curveto(36, 69, 46, 92);moveto(49, 75);curveto(48, 86, 55, 92); work_tree = function (tree_no, speed_time) { this.createemptymovieclip("tree" tree_no, tree_no); // trace("tree_name=" "tree" tree_no); telltarget ("tree" tree_no) { linestyle(1, 0x000000, 100); moveto(0, -54); curveto(-21, -42, -23, -20); curveto(-18, 17, -5, 24); linestyle(1, 0x000000, 100); moveto(0, -54); curveto(22, -42, 23, -20); curveto(18, 17, 5, 24); linestyle(0.25, 0x000000, 100); moveto(-5, 24); lineto(-5, -7); curveto(1, 5, 5, -8); lineto(5, 24); linestyle(1, 0x000000, 100); moveto(-5, 24); lineto(-5, 55); lineto(5, 55); lineto(5, 24); // ------------ this["tree" tree_no]._xscale = speed_time; this["tree" tree_no]._yscale = speed_time; this["tree" tree_no]._alpha = speed_time-20; this["tree" tree_no]._y = 75; this["tree" tree_no].onenterframe = function() { this._x = this._x speed_time/15; if (this._x>=500) { this.clear(); this.onenterframe = undefined; this.removemovieclip(); } }; }};work_play_caput = function (path) { this[path].createemptymovieclip("play_caput", 2000); telltarget (this[path]["play_caput"]) { linestyle(0.25, 0x000000, 100); beginfill(0x000000, 100); moveto(0, -10); curveto(-10, -8, -10, 0); curveto(-8, 10, 0, 10); curveto(10, 8, 10, 0); curveto(8, -10, 0, -10); }};work_play1_run = function (x, y, xscale, yscale) { this.createemptymovieclip("play1_run", 1000); work_play_caput("play1_run"); play1_run._xscale = xscale; play1_run._yscale = yscale; play1_run._x = x; play1_run._y = y; telltarget ("play1_run") { play_caput._xscale = 65; play_caput._yscale = 65; play_time = 0; this.play1_run.onenterframe = function() { this.play_time ; telltarget (this) { if (play_time == 1) { clear(); play_caput._x = 17; play_caput._y = 5; linestyle(3, 0x000000, 100); moveto(15, 10); lineto(7, 15); lineto(2, 22); moveto(15, 10); lineto(20, 17); lineto(28, 17); moveto(15, 10); lineto(12, 20); lineto(12, 28); moveto(12, 28); lineto(7, 40); lineto(0, 45); lineto(3, 48); moveto(12, 28); lineto(20, 35); lineto(15, 40); lineto(16, 42); } else if (play_time == 3) { clear(); play_caput._x = 23; play_caput._y = 5; linestyle(3, 0x000000, 100); moveto(21, 11); lineto(10, 14); lineto(5, 20); moveto(21, 11); lineto(27, 18); lineto(35, 15); moveto(21, 11); lineto(18, 20); lineto(16, 30); moveto(16, 30); lineto(10, 35); lineto(1, 40); lineto(0, 43); moveto(16, 30); lineto(22, 33); lineto(27, 41); lineto(30, 43); } else if (play_time == 5) { clear(); play_caput._x = 25; play_caput._y = 5; linestyle(3, 0x000000, 100); moveto(22, 11); lineto(10, 16); lineto(8, 24); moveto(22, 11); lineto(25, 20); lineto(32, 18); moveto(22, 11); lineto(18, 21); lineto(18, 30); moveto(18, 30); lineto(10, 35); lineto(2, 35); lineto(0, 36); moveto(18, 30); lineto(22, 36); lineto(25, 47); lineto(30, 47); } else if (play_time == 7) { clear(); play_caput._x = 18; play_caput._y = 6; linestyle(3, 0x000000, 100); moveto(15, 11); lineto(13, 18); lineto(16, 20); moveto(15, 11); lineto(11, 18); lineto(14, 25); moveto(15, 11); lineto(12, 20); lineto(11, 25); moveto(11, 25); lineto(16, 36); lineto(9, 36); lineto(10, 38); moveto(11, 25); lineto(12, 35); lineto(10, 45); lineto(13, 45); } else if (play_time == 8) { play_time = 0; } } }; }};work_play2_arise = function () { this.createemptymovieclip("play2_arise", 2000); work_play_caput("play2_arise"); telltarget ("play2_arise") { play_caput._x = 2; play_caput._y = -20; linestyle(4, 0x000000, 100); moveto(-7, -5); lineto(6, -7); moveto(-4, -9); lineto(5, -3); moveto(1, -11); lineto(0, 10); moveto(0, 10); lineto(1, 23); lineto(-3, 35); lineto(2, 35); moveto(0, 10); lineto(-6, 21); lineto(4, 29); lineto(1, 33); }};player_run = function () { clear(); linestyle(5, 0x000000, 100); moveto(sx, sy); lineto(zs1x, zs1y); lineto(zs2x, zs2y); moveto(sx, sy); lineto(ys1x, ys1y); lineto(ys2x, ys2y); moveto(sx, sy); lineto(st1x, st1y); lineto(st2x, st2y); moveto(st2x, st2y); lineto(zj1x, zj1y); lineto(zj2x, zj2y); lineto(zj3x, zj3y); moveto(st2x, st2y); lineto(yj1x, yj1y); lineto(yj2x, yj2y); lineto(yj3x, yj3y); setproperty("/tou2", _x, toux2); setproperty("/tou2", _y, touy2); linestyle(5, 0x930093, 100); moveto(sx2, sy2); lineto(zs1x2, zs1y2); lineto(zs2x2, zs2y2); moveto(sx2, sy2); lineto(ys1x2, ys1y2); lineto(ys2x2, ys2y2); moveto(sx2, sy2); lineto(st1x2, st1y2); lineto(st2x2, st2y2); moveto(st2x2, st2y2); lineto(zj1x2, zj1y2); lineto(zj2x2, zj2y2); lineto(zj3x2, zj3y2); moveto(st2x2, st2y2); lineto(yj1x2, yj1y2); lineto(yj2x2, yj2y2); lineto(yj3x2, yj3y2);};//---------------------new_load_data---------------------tree_play_time = 0;tree_no = 0;play_time = 0;//work_play_caput();//play_caput._visible = false;//---------------------start_play---------------------trees_play = function () { // ↓每当播放速度值达到15时 复制一棵树 if (tree_play_time == 15) { // ↓随机产生每一棵树的大小及移动的速度 speed_time = int(random(50)) 30; // 制造树 work_tree(tree_no, speed_time); tree_no ; tree_play_time = 0; } tree_play_time ;};this.onenterframe = function() { play_time ; //放置人物1跑动 if (play_time == 1) { work_play1_run(319, 94, -150, 150); } //树移动 trees_play();}; 按ctrl enter测试吧! 上一篇: MVC页面扩展方法 单例模式 下一篇: java null与空的区别有哪些 推荐阅读 用纯Flash Actionscript做的火柴棍小人跑的动画 用纯Flash Actionscript做的火柴棍小人跑的动画