Notice
Recent Posts
Recent Comments
Link
«   2024/07   »
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31
Archives
Today
Total
관리 메뉴

브래의 슬기로운 코딩 생활

모바일 게임 개발 10주차 정리 본문

2-1/모바일 게임 개발

모바일 게임 개발 10주차 정리

김브래 2023. 5. 10. 18:39

오늘은 고양이가 떨어지는 화살표를 피해야하는 간단한 게임을 만들었다.

사용된 개념

 

int px = Random.Range(-3, 4); 

:-3~3의 값 중 임의의 값이 px에 저장

 

public GameObject arrowPrefab;//화살표에 연결

 

//arrowPrefab이 복제됨

void Update(){

GameObject go = Instantiate(arrowPrefab) as GameObject

}

 

void Update() {

  GameObject go = Instantiate(arrowPrefab) as GameObject;

  int px = Random.Range(-3, 4);

  go.transform.position = new Vector3(px, 7, 0);

  }

 

Time.deltaTime

프레임을 처리하는데 걸리는 시간

 

GameObject.Find(); / Destroy(gameObject);

 

director.GetComponent<GameDirector>().DecreaseHp();

GameDirector 소스코드 안에 있는 DecreaseHp함수 호출

 

Vector2 p1 = transform.position; //사과의 중심좌표

Vector2 p2 = this.player.transform.position; // 고양이의 중심좌표

Vector2 dir = p1 - p2;

float d = dir.magnitude;// magnitude: dir (p1과 p2의 위치차이)의 거리를 피타고라스 정리에 의해 계산하는 함수