每天學習一點flash(35) 遊戲設計筆記 (5) 跳躍演算法筆記

來源:互聯網
上載者:User

這幾天都在嘗試看一些物理的資料 ,但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);
    }
   
   
}
 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.