-
Notifications
You must be signed in to change notification settings - Fork 44
MapViewer
fro Camera
#2172
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MapViewer
fro Camera
#2172
Conversation
PR Review for #2172Starting code review for the map editor implementation... Todo List:
🔍 Code Review SummaryThis PR implements a comprehensive map editor feature with physics support and camera functionality. Overall, the implementation shows good architectural patterns, but there are several areas for improvement. 🏗️ Architecture & Design✅ Strengths:
|
Skipping CI for Draft Pull Request. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这次把 custom-transformer、Nodetransformer、SpriteNode 等比较容易抽出来的做了下复用,在src/components/editor/common/viewer/
目录下
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.
This PR has been deployed to the preview environment. You can explore it using the preview URL. Warning Please note that deployments in the preview environment are temporary and will be automatically cleaned up after a certain period. Make sure to explore it before it is removed. For any questions, contact the XBuilder team. |
function inViewport({ x, y }: Pos) { | ||
if (viewportSize.value == null) return true | ||
const xInViewport = (x + mapSize.value.width / 2) * mapScale.value + mapPos.value.x | ||
const yInViewport = (-y + mapSize.value.height / 2) * mapScale.value + mapPos.value.y | ||
return ( | ||
xInViewport >= 0 && | ||
xInViewport <= viewportSize.value.width && | ||
yInViewport >= 0 && | ||
yInViewport <= viewportSize.value.height | ||
) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里的Pos
指的是spx
的Sprite
的x, y
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
类型 Pos
本身是跟坐标系无关的,不管在哪个坐标系里的位置,都可以是 Pos
类型的数据
如注释
/** Check if given position (in game) is in viewport */ function inViewport({ x, y }: Pos) {
所述,这里 inViewport
的参数 { x, y }: Pos
预期是游戏世界(舞台)坐标系的,如 sprite 的 x、y
close #2147.