2 부 : 레트로 개조 및 향상된 게임 플레이
클래식 스타일링 :
흑백 스프라이트 수입, 정통 레트로 비주얼을 위해 단위당 픽셀 (64). 기본 카메라 배경을 검은 색으로 변경하고 그에 따라 패들 및 볼 스프라이트를 업데이트하십시오. 여러 개의 스케일링 된 흰색 스프라이트를 사용하여 중앙 분배기를 만듭니다 강화 충돌 : 패들의 충격 각도를 계산하기 위해 볼 충돌 처리를 개선하여 층이 더 현실적입니다. 여기에는 함수를 사용하기 위해 스크립트의 메소드를 업데이트하는 것이 포함됩니다. 플레이어와 적의 패들에 적절하게 태그를 지정해야합니다. 개선 된 적 AI : 시간 기반 계산을 사용하여 부드러운 적의 패들 움직임, 응답 성 및 도전을 향상시킵니다.BallController
OnCollisionEnter2D
코드 스 니펫 : (BallController.cs -OnCollisionEnter2d & 런치 앵이) (EnemyController.cs -Move)
void OnCollisionEnter2D(Collision2D col) { if (col.gameObject.tag == "Enemy") { float y = launchAngle(transform.position, col.transform.position, col.collider.bounds.size.y); Vector2 d = new Vector2(1, y).normalized; rig2D.velocity = d * speed * 1.5F; } if (col.gameObject.tag == "Player") { float y = launchAngle(transform.position, col.transform.position, col.collider.bounds.size.y); Vector2 d = new Vector2(-1, y).normalized; rig2D.velocity = d * speed * 1.5F; } } float launchAngle(Vector2 ball, Vector2 paddle, float paddleHeight) { return (ball.y - paddle.y) / paddleHeight; }
<<> (uimanager.cs -partial)
void Move() { if (ball == null) { ball = GameObject.FindGameObjectWithTag("Ball").transform; } ballRig2D = ball.GetComponent<Rigidbody2D>(); if (ballRig2D.velocity.x > 0) { if (ball.position.y > this.transform.position.y + .5F) { transform.Translate(Vector3.up * speed * Time.deltaTime); } else if (ball.position.y < this.transform.position.y - .5F) { transform.Translate(Vector3.down * speed * Time.deltaTime); } } // ... bounds checking ... }
<<> (gameover.cs)
// ... other methods ... public void showFinished() { foreach (GameObject g in finishObjects) { g.SetActive(true); } } // ... other methods ...
위 내용은 UI 및 게임 플레이에서 통합 클론 구축의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!