[fix] 내용이 빈 글상자로 충돌·튕기기 블록 실행 시 오류 나는 문제 수정#3079
Open
205sla wants to merge 2 commits into
Open
Conversation
There was a problem hiding this comment.
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(); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
작업 내용
내용이 비어 있는 글상자가
~에 닿았는가?(reach_something)나화면 끝에 닿으면 튕기기(bounce_wall) 블록을 실행할 때, 부스트 모드가 꺼진(캔버스 렌더러) 상태에서TypeError로 스크립트가 중단되던 문제를 수정합니다.재현
시작하기 버튼을 클릭했을 때( )(이)라고 글쓰기— 내용을 빈 문자열로만일 <(엔트리봇)에 닿았는가?> (이)라면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가 항상 존재하므로 이 가드가 동작하지 않아 기존 동작이 그대로 유지됩니다.
검증