Invalid pointer world position when camera/world scale is not 1 or world rotation is not 0
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 30/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- javascript
- Lĩnh vực
- game-dev
Hướng nghiên cứu
The issue provides a JavaScript example using game.input.mousePointer, game.camera, and game.world, but names no source files or tests. Start by tracing how pointer worldX and worldY are calculated and how camera and world transforms are applied. Done means pointer world position stays correct when world scale or rotation changes, including the cases shown in the example.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
If world scale is not 1 or rotation is not 0 pointer world position will be invalid.
Sample code:
var sprite;
function preload() {
game.load.baseURL = 'http://examples.phaser.io/assets/';
game.load.crossOrigin = 'anonymous';
game.load.image('phaser', 'sprites/phaser-dude.png');
}
function create() {
game.world.position.set(100,100);
if (1)
{
game.world.scale.set(0.5,0.5);
}
if (1)
{
game.world.rotation = Math.PI * 45 / 180;
}
sprite = game.add.sprite(0, 0, 'phaser');
sprite.anchor.set(0.5, 0.5);
}
function update() {
var pointer = game.input.mousePointer;
sprite.x = pointer.worldX;
sprite.y = pointer.worldY;
}
Temporary workaround:
var sprite;
function preload() {
game.load.baseURL = 'http://examples.phaser.io/assets/';
game.load.crossOrigin = 'anonymous';
game.load.image('phaser', 'sprites/phaser-dude.png');
}
function create() {
game.world.position.set(1000,1000);
if (1)
{
game.world.scale.set(0.5,0.5);
}
if (1)
{
game.world.rotation = Math.PI * 15 / 180;
}
sprite = game.add.sprite(0, 0, 'phaser');
sprite.anchor.set(0.5, 0.5);
}
function update() {
var pointer = game.input.mousePointer;
var camera = game.camera;
var world = game.world;
var rotation = -world.rotation;
var sin = Math.sin(rotation);
var cos = Math.cos(rotation);
var tmpX = (pointer.x + camera.position.x) / camera.scale.x;
var tmpY = (pointer.y + camera.position.y) / camera.scale.y;
var worldX = tmpX * cos - tmpY * sin;
var worldY = tmpX * sin + tmpY * cos;
sprite.x = worldX;
sprite.y = worldY;
}
- Ngôn ngữ chính
- JavaScript
- Star
- 1.4k
- Fork
- 485
- Merge trung bình
- 1 ngày 2 giờ
- Pull request đã merge (30 ngày)
- 9
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của phaserjs/phaser-ce
-
Web audio stops playing in iOS 17 and 18 after refocusingCó thể làm lại được @samme đã nhận 633 ngày trước và không có pull request nào đang mở. Đang mở
phaserjs/phaser-ce#748 · 2 reaction · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
phaserjs/phaser-ce#740 · 9 bình luận · 2 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 25/100
phaserjs/phaser-ce#724 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 25/100
phaserjs/phaser-ce#711 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 25/100
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của phaserjs/phaser-ce
Issue tương tự
-
enhancement ready
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
-
enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
DCGM/semant-demo#708 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
-
agents area: runtime automation chore cli consistency dependencies developer-experience difficulty: easy documentation enhancement good first issue help wanted hygiene json-output priority: P3 starters tests
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Client codegen: an import repeated in an impl file is emitted twice, and the browser rejects the moduleCó thể đã có người làm @MalithaPrabhashana đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 64/100
jaseci-labs/jac#10756 ·
Maintainer thường phản hồi trong vòng 1 ngày