Game-Week2)

gyu·2023년 1월 22일
0

game-unity

목록 보기
2/5

이미지없이 animation 만들기
-recording button 사용해서 element의 sprite 스냅샷을 찍어 애니메이션 표현하기

click element- 상태변화를 원하는 시간대 클릭 - 원하는 모습으로 바꾸기(ex ) color, size...)


마우스를 이용해서 요소의 위치 구현하기
1) 마우스 위치 찾기
-unity에서 제공

Vector3 mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
transporm.position = new Vector3(mousePos.x, mousePos.y, 0);

2) 마우스 위치와 요소의 위치를 같게 하기


게임에 최고점 나타내기 위해서...
최고점을 저장하는 기능 생각해보기
-playerPrefs.set을 사용해서 데이터를 보관하기(특징: key- value pair로 저장해야함)

데이터 저장하기(set)
PlayerPrefs.SetFloat("Score", 숫자열);
PlayerPrefs.SetString("Score", 문자열);

데이터 불러오기(get)
숫자열 = PlayerPrefs.getFloat("Score");
문자열 = PlayerPrefs.getString("Score");
 
데이터 저장했는 지 확인(HasKey - 있으면 true, 없으면 false)
PlayerPrefs.HasKey("Score");

데이터 모두 지우기
PlayerPrefs.DeleteAll();
  • 최고 점수가 없으면 현재점수 = 최고점수 지정
    이미 있으면 최고점수와 현재점수와 비교해서 크면 현재점수를 작으면 원래 최고점수를 최고점수로 지정
profile
#TechExplorer 🚀 Curious coder exploring the tech world, documenting my programming journey in a learning journal

0개의 댓글