기존 alert()나 confirm()을 이용해 다음 스테이지 이어달리기 또는 로비로 돌아가기 기능을 구현했었다. 기능은 잘 동작하지만 전체 UI와 맞지 않는 디자인이다 보니 이질감이 생겼다. 이번에는 쿠키런과 비슷한 디자인으로 확인창을 디자인 해봤다.
확인창을 띄우는 방법은 paused 박스나 crash_filter를 띄우는 방식과 동일하다. 확인창을 디자인한 후 display: none;으로 설정하고, 스테이지를 클리어하면 display: block;으로 변경하면 된다.
기존에 alert()과 confirm()을 사용할 때와 내부적인 코드는 동일하기 때문에 금방 만들 수 있었다.
const nextStage = () => {
cookie.movex = 0;
gameBackground.gameBox.style.transform = `translateX(${0}px)`;
allJellyComProp.arr.forEach((j) => {
j.el.remove();
});
allJellyComProp.arr.splice(0); //배열 요소 전부 삭제
allObstacleComProp.arr.forEach((o) => {
o.el.remove();
});
allObstacleComProp.arr.splice(0);
allItemComProp.arr.forEach((i) => {
i.el.remove();
});
allItemComProp.arr.splice(0);
newStage = new Stage(stageInfo.stage[stageInfo.currentStageIndex]);
stageInfo.currentStage = newStage;
gameProp.gameClear = false;
document.querySelector(".stage_guide").style.display = "none";
};
const backLobby = () => {
cookie.movex = 0;
gameBackground.gameBox.style.transform = `translateX(${0}px)`;
allJellyComProp.arr.forEach((j) => {
j.el.remove();
});
allJellyComProp.arr.splice(0);
allObstacleComProp.arr.forEach((o) => {
o.el.remove();
});
allObstacleComProp.arr.splice(0);
allItemComProp.arr.forEach((i) => {
i.el.remove();
});
allItemComProp.arr.splice(0);
location.href = "index.html";
document.querySelector(".stage_guide").style.display = "none";
};
모든 스테이지를 클리어했을 때는 다른 확인창을 띄운다.
🔻모든 코드 보기🔻
https://github.com/mkthebea/CCKK_Run.git
GitHub - mkthebea/CCKK_Run: A fangame of [CookieRun: Ovenbreak]
A fangame of [CookieRun: Ovenbreak]. Contribute to mkthebea/CCKK_Run development by creating an account on GitHub.
github.com
🔻게임 하기🔻
https://mkthebea.github.io/CCKK_Run/
DAL GGA
Loading... No Record Bronze Silver Gold Ruby Diamond Rainbow
mkthebea.github.io
728x90
'달리는 까까: 쿠키런 팬게임' 카테고리의 다른 글
[달리는 까까] 맵 제작하기 (0) | 2022.06.05 |
---|---|
[달리는 까까] 아이템 추가 (0) | 2022.06.02 |
[달리는 까까] 스테이지 이어 달리기 (0) | 2022.06.02 |
[달리는 까까] 이미지 사전 로드와 로딩 페이지 (0) | 2022.05.31 |
[달리는 까까] 메인 화면을 로비로 만들기 (0) | 2022.05.31 |