2016-06-19 10 views
0

Mein Ziel ist ein Sprite größer als der Bildschirm zu machen und die Benutzer blättern haben die verschiedenen Teile davon zu sehen, so wollte ich fragen, ob Phaser Jeder Sprite eventListener -Funktionen hatte wie:Phaser Scrollen Hintergrund

var canvas = window.document.getElementsByTagName('canvas')[0], 
     prevX = 0, prevY = 0, mouseDown = false; 

wo Leinwand als

canvas.addEventListener('mousedown',function(e){ 
    }); 

    canvas.addEventListener('mousemove',function(e){ 
    }); 

Antwort

0

hier verwendet wird, ist, wie ich es tat.

In Ihrer Update-Funktion:

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; 
}