我的目标是制作一个比屏幕更大的 Sprite ,并让用户滚动查看它的不同部分,所以我想问 Phaser 是否有任何 Sprite eventListener
功能,例如:
var canvas = window.document.getElementsByTagName('canvas')[0],
prevX = 0, prevY = 0, mouseDown = false;
Canvas 可以用作
canvas.addEventListener('mousedown',function(e){
});
canvas.addEventListener('mousemove',function(e){
});
最佳答案
这是我的做法。
在您的更新函数中:
if (this.game.input.activePointer.isDown) {
if (this.game.origDragPoint) {
// move the camera by the amount the mouse has moved since last update
this.game.camera.x += this.game.origDragPoint.x - this.game.input.activePointer.position.x;
this.game.camera.y += this.game.origDragPoint.y - this.game.input.activePointer.position.y;
}
// set new drag origin to current position
this.game.origDragPoint = this.game.input.activePointer.position.clone();
}
else {
this.game.origDragPoint = null;
}
关于javascript - 移相器滚动背景,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37902960/