2005/12/14 | 射击类游戏的开发过程(Flash)(八)
类别(Flash) | 评论(0) | 阅读(69) | 发表于 14:04
9、敌机的曲线飞行

这里要说到的是一种比较简单的锯齿飞行路线,直线的飞行是修改X轴的属性,锯齿飞行需要修改y轴的属

性,只需要y轴的值在一个较小的范围内变化就可达到这个目的。



先确定一下飞行的最高点和最低点(以当前的y轴为基点):

maxH=this._y+100;
minH=this._y-100;

飞行的速度:

upspeed=2;
--------------------
this._y += upspeed;
 
if (this._y > maxH)
{
  upspeed = -2;
}
else if (this._y < minH)
{
  upspeed = 2;
}

根据范围来修改upspeed的值。

完整的代码是这样的:
onClipEvent (enterFrame)
{
  this._x -= enemySpeed;
  this._y += upspeed;
 
if (this._y > maxH)
{
  upspeed = -2;
}
else if (this._y < minH)
{
  upspeed = 2;
}

  if (this._x < -10)
  {
    reset();
  }
if (this.hitTest(_root.hero))
{
  _root.gotoAndStop(2);
}

}




0
这条日志目前没有评论.

发表留言post

用 户Name:
密 码Password:
内 容Comment:
http://www.5d.cn/images/size_down.gif http://www.5d.cn/images/size_up.gif
验 证Verify:
日志分类
首页[185]
Flash[123]
ColdFusion[2]
Flex[2]
FlashMedia[3]
RIA[4]
Other[43]
Python[0]
Design[8]