Skip to content

[fix] 내용이 빈 글상자로 충돌·튕기기 블록 실행 시 오류 나는 문제 수정#3079

Open
205sla wants to merge 2 commits into
entrylabs:developfrom
205sla:fix/empty-textbox-collision
Open

[fix] 내용이 빈 글상자로 충돌·튕기기 블록 실행 시 오류 나는 문제 수정#3079
205sla wants to merge 2 commits into
entrylabs:developfrom
205sla:fix/empty-textbox-collision

Conversation

@205sla

@205sla 205sla commented Jul 3, 2026

Copy link
Copy Markdown

작업 내용

image

내용이 비어 있는 글상자가 ~에 닿았는가?(reach_something)나 화면 끝에 닿으면 튕기기(bounce_wall) 블록을 실행할 때, 부스트 모드가 꺼진(캔버스 렌더러) 상태에서 TypeError로 스크립트가 중단되던 문제를 수정합니다.

재현

  1. 글상자 오브젝트를 추가합니다.
  2. 다음과 같이 블록을 조립합니다.
    • 시작하기 버튼을 클릭했을 때
    • ( )(이)라고 글쓰기 — 내용을 빈 문자열로
    • 만일 <(엔트리봇)에 닿았는가?> (이)라면
  3. 부스트 모드를 끈 상태로 실행하면, 글쓰기로 글상자가 비는 순간 닿았는가? 판정에서 Cannot read properties of null (reading 'y') 오류가 발생하며 스크립트가 멈춥니다.

~에 닿았는가?의 벽 판정과 화면 끝에 닿으면 튕기기도 같은 원인으로 reading 'x' 오류가 발생합니다.

원인

캔버스(EaselJS) 렌더러에서 내용이 빈 글상자는 경계 사각형(bounds)이 null이 됩니다. createjs.Text는 텍스트가 빈 문자열이면 getBounds()null을 반환하고 배경 도형에도 bounds가 없어서 글상자 컨테이너 전체의 getTransformedBounds()null이 되기 때문입니다.

null이 아래 세 경로에서 가드 없이 그대로 사용됩니다.

  • reach_something의 글상자 분기가 이 값을 Entry.checkCollisionRect에 넘겨 rectA.y를 참조하는 지점에서 오류가 납니다.
  • reach_something의 벽 분기가 호출하는 ndgmr.checkPixelCollision_collisionDistancePrecheck에서 ir1.x를 참조하는 지점에서 오류가 납니다.
  • bounce_wall도 같은 벽 충돌 경로를 사용하므로 동일하게 오류가 납니다.

WebGL(부스트 모드) 렌더러는 빈 글상자에도 최소 크기 텍스처를 만들어 bounds가 항상 존재하므로 이 오류가 발생하지 않습니다.

수정

넓이가 없어 bounds를 구할 수 없는 글상자는 아무것과도 닿지 않은 것으로 처리합니다. 같은 블록 함수 상단에서 보이지 않는 오브젝트를 처리하는 방식(!sprite.getVisible()이면 false 반환)과 같은 취지입니다.

  • reach_something 함수 앞부분에서, 자신이 글상자이고 bounds가 없으면 false를 반환합니다.
  • Entry.checkCollisionRect에 두 사각형 중 하나라도 없으면 false를 반환하는 가드를 추가합니다. 대상이 빈 글상자인 반대 방향과 복제본 판정까지 함께 처리됩니다.
  • bounce_wall 함수 앞부분에서, 자신이 글상자이고 bounds가 없으면 튕기지 않고 넘어갑니다.

WebGL 렌더러는 bounds가 항상 존재하므로 이 가드가 동작하지 않아 기존 동작이 그대로 유지됩니다.

검증

  • 수정 전 오류가 나던 네 경로(글상자→스프라이트, 스프라이트→글상자, 글상자→벽, 빈 글상자 튕기기)가 모두 오류 없이 처리됩니다.
  • 내용이 있는 글상자의 충돌 판정은 그대로입니다(겹치면 참, 떨어지면 거짓).
  • WebGL 렌더러에서 판정 결과가 수정 전과 동일합니다.

Copilot AI review requested due to automatic review settings July 3, 2026 08:05

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

캔버스(EaselJS) 렌더러에서 내용이 빈 글상자(textBox) 의 bounds가 null이 되는 경우, ~에 닿았는가?(reach_something)화면 끝에 닿으면 튕기기(bounce_wall) 실행 중 TypeError로 스크립트가 중단되던 문제를 방지하기 위한 가드(early return) 및 충돌 판정 유틸 가드를 추가한 PR입니다.

Changes:

  • Entry.checkCollisionRect에 입력 사각형이 null일 때 false를 반환하는 가드 추가
  • bounce_wall에서 빈 글상자(bounds null)인 경우 벽 충돌 계산을 건너뛰도록 처리
  • reach_something에서 빈 글상자(bounds null)인 경우 충돌 판정을 false로 처리

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/util/utils.js 충돌 사각형 입력이 null일 때 예외 대신 비충돌(false) 처리하도록 가드 추가
src/playground/blocks/block_moving.js bounce_wall에서 빈 글상자(bounds null) 조기 반환 처리 추가
src/playground/blocks/block_judgement.js reach_something에서 빈 글상자(bounds null)를 항상 비충돌로 처리하는 가드 추가

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +117 to +122
if (
sprite.type === 'textBox' &&
!GEHelper.getTransformedBounds(sprite.object)
) {
return script.callReturn();
}

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

반영했습니다(d396cda).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants