글

라벨이 보인 게시물 표시

10강 슈팅게임 만들기 - 복습

===[ PLAYER ]============================================================ using UnityEngine; using System.Collections; // ui 를 사용할때 반드시 사용 해줘야 함. using UnityEngine.UI; // 스피드 변수 생성 // 이동값 입력받음 // 이동값 대입 // 이동제한 public class CPlayer : MonoBehaviour { public int _hp = 100; public int _score; //스코어 public Text scoreText; //이미지바 public Image hpBar; //폭파 이펙트 public Object Explo_effect; public float speed = 5; Vector2 pos; // Use this for initialization void Start() { } // Update is called once per frame void Update() { float h = Input.GetAxis("Horizontal"); // 이동 메소드 transform.Translate(Vector2.right * h * speed * Time.deltaTime); // 이동제한 메소드 실행 CheckArea(); } // 이동제한 메소드 2.8 void CheckArea() { pos = transform.position; if (pos.x <= -2.8f) pos.x = -2.8f; if (pos.x >= 2.8f) pos.x = 2.8f; transform.pos...