コード例 #1
0
ファイル: Score.cs プロジェクト: ernestoivan22/slime_game
    /*void onTriggerEnter2D(Collider2D col){
     *      print ("choque!");
     *      if (col.gameObject.tag == "ball") {
     *              print ("tierra!");
     *      }
     * }*/
    void OnCollisionEnter2D(Collision2D collision)
    {
        ContactPoint2D[] contacto = collision.contacts;
        Vector2          puntos   = contacto[0].point;

        if (collision.gameObject.name == "ball")
        {
            if (puntos.x < 0)
            {
                gManager.AddScore(1);
            }
            else
            {
                gManager.AddScore(0);
            }
        }
    }
コード例 #2
0
ファイル: enemy.cs プロジェクト: MFbuider/moon_2D_game_3
 /// <summary>
 /// 死亡
 /// </summary>
 private void Dead()
 {
     enabled = false;
     ani.SetBool("death Bool", true);
     GetComponent <CapsuleCollider2D>().enabled = false;      // 關閉碰撞器
     rig.Sleep();
     //Destroy(gameObject, 2.5f);                              // 刪除(遊戲物件,延遲秒數)
     gm.AddScore(score);
 }