수리검이 날아가지 않습니다
221
작성한 질문수 4
const renderGame에서 keyMotion()까지는 작동을 하는데그 이후 forEach부분부터는 작동하지 않는것같습니다, 왜이럴까요?오타도 없고 아무이상없습니다!혹시 window.requestAnimationFrame이 너무 빨라서 bulletComProp foreach가 씹히는걸까요? ㅠㅠ... 코드 보내드립니다<game.js>
const renderGame = () => {
hero.keyMotion();
bulletComProp.arr.forEach((arr,i)=>{
arr.moveBullet();
})
window.requestAnimationFrame(renderGame);
}
<class.js>
if(key.keyDown['attack']){
this.el.classList.add('attack');
bulletComProp.arr.push(new Bullet());
}
class Bullet {
constructor(){
this.parentNode = document.querySelector(".game");
this.el = document.createElement("div");
this.el.className = "hero_bullet";
this.x = 0;
this.y = 0;
this.speed = 30;
this.distance = 0;
this.init();
}
init(){
this.x = hero.position().left + hero.size().width/2;
this.y = hero.position().bottom - hero.size().height/2;
this.el.style.transform = `translate(${this.x}px, ${this.y}px)`;
this.parentNode.appendChild(this.el);
}
moveBullet(){
this.distance += this.speed;
this.el.style.transform = `translate(${this.distance}px, 100)`;
this.el.style.backgroundColor = 'red';
}
}
답변 1
배리어블 목록 없음
0
10
2
Token 등록 방법 문의
0
13
1
프로젝트 완성본 보내주실수 있나요?
0
50
1
캐릭터 기본 모션 만들기에서 포토샵에 열라고하는데 포토샵없으면 어떻게하죠? 공짜버전있나요?
0
191
1
renderGame 함수에 로그를 찍으면 무한루프가 돕니다
0
282
1
수리검 방지턱(?) 현상
0
486
2
requestanimationframe 성능관련 궁금증
0
594
1
frame 질문합니다.
0
341
2
개발툴은 어떤걸 사용하나요?
0
293
1
e.which에 대한 질문입니다.
1
602
1
수리검이 사라집니다
0
272
1
const 변수 및 Arrowfunction 방식 질문
0
423
2
몬스터나 npc의 위치가 일정 크기를 넘어가면 히어로가 사라집니다.
0
190
1
수리검 방향 전환 처리에서 간단한 질문 있습니다.
0
219
1
마이너스 좌표값(?) 사용
0
739
1
코딩작업하고 웹화면 띄워서 확인하는 방법?
0
522
2
캐릭터가 점프하면서 앞으로 나아가게 만들고있습니다
0
383
1
전체 이미지에서 원하는 부분만 컷하고 싶어요(사진첨부)
0
478
1
질문있습니다.
0
196
1
깃헙 레포 질문드립니다.
0
250
1
캐릭터 기본 모션 만들기, 경로가 인식이 안되요.
0
291
1
몬스터가 참조가 안되는 이슈가 있습니다.
0
346
1
기초적인 질문이라 부끄럽지만 질문 드립니다
0
404
1
공격키를 연속으로 누를때 처리하는 방법 질문 드립니다
0
927
2





