《天弋夺宝》—01飞船的控制

时间:2022-04-22
本文章向大家介绍《天弋夺宝》—01飞船的控制,主要内容包括其使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。

《天弋夺宝》—01飞船的控制

作飞船类的小游戏首先需要控制飞船。

设置场景为30.fps。在场景内绘制一个飞船的MC。取名ship_mc

在场景内最上层第一帧写代码。

//首先创建一个ship的对象 var ship = new Object(); /*指定ship_mc就是场景中的ship_mc这样做的好处是在以后 如果ship_mc放到的别的MC中,方便寻找,以免路径出错提 示“找不到对象”*/ var ship_mc = _root.ship_mc; //初始化 ship.Init = function() { //定义初始坐标     ship_mc._x = 40;     ship_mc._y = 40; //垂直于水平速度     ship.dy = 1;     ship.dx = 0; //启用控制     ship.ent(); }; //控制ship ship.ent = function() {     ship_mc.onEnterFrame = function() { //座移动 if (Key.isDown(Key.LEFT)) {             ship.dx = ship.dx-0.100000;             ship_mc._xscale = -100;         } //右移动 if (Key.isDown(Key.RIGHT)) {             ship.dx = ship.dx+0.100000;             ship_mc._xscale = 100;         } //向上飞 if (Key.isDown(Key.UP)) {             ship.dy = ship.dy-0.300000;         } //设置ship坐标         ship_mc._x = ship_mc._x+ship.dx*1.500000;         ship_mc._y = ship_mc._y+ship.dy*1.300000;         ship.dy = ship.dy+0.070000; //转动角度         ship_mc._rotation = 10*ship.dx;     }; }; //调用初始化函数 ship.Init();

/Files/nasa/01_ship.rar 相关文章: <天弋夺宝> 核心代码(未注释) 《天弋夺宝》—01飞船的控制

在这里观看完整作品 http://www.flashempire.com/peak/view_flash.php?id=158

若觉得本文您有所帮助请给我的作品投上您宝贵的一票。你有可能成为新运网友哦~