这几天都在尝试看一些物理的资料 ,但as3.0模拟跳跃的时候总是会错,这是下面某一个游戏的代码,我把他改了一些 减少了很多代码,算是最简单的跳跃实验吧,还是可以的。有兴趣的话可以试试,不过 as3.0 真的不太熟悉呢? 觉得 2.0 熟悉了 , 

还是要看一下 物理斜抛 和上抛的公式 ,努力继续努力每天多学习

onClipEvent (load)
{
    function move(x, y)
    { 
       this._x+=Math.cos(_rotation * Math.PI/180) * x;
    this._y+=Math.sin(_rotation * Math.PI/180)*x;
 
        if (!_root.map.hitTest(_x, _y + y, true))
        {
            this._y+=y;
        }
    }
  
}
onClipEvent (enterFrame)
{
    if (Key.isDown(Key.UP) && !jump)
    {
        jump = true;
        vy = -10;
    }
    if (jump)
    {
        move(0, -5);
        move(0, vy++);
  trace(vy);
        if (vy > 14)
        {
            jump = false;
        }
    }
    if (1)
    {
        move(0, 5);//下落的速度
      
    }
    if (Key.isDown(Key.RIGHT))
    {
     
            move(5, 0);
     }
     
 
    if (Key.isDown(Key.LEFT))
    {
         move(-5, 0);
    }
   
   
}

相关文章:

  • 2022-03-09
  • 2022-12-23
  • 2021-07-10
  • 2021-12-17
  • 2021-07-18
  • 2022-01-20
  • 2021-05-15
  • 2021-09-28
猜你喜欢
  • 2021-05-17
  • 2021-10-06
  • 2021-11-10
  • 2021-09-27
  • 2022-01-14
  • 2021-09-29
  • 2021-06-12
相关资源
相似解决方案