Last active
May 6, 2018 17:35
-
-
Save JetLua/531378aa69d9ecbaa6458a7584c77b88 to your computer and use it in GitHub Desktop.
phaser 旋转画布后的点击事件映射
This file contains 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
// game.rotation: 画布的旋转角度,可简化为landscape | portrait | |
Object.defineProperties(phaser.Input.Pointer.prototype, { | |
x: { | |
get() { | |
return config.landscape ? this.position.y / this.manager.bounds.width * this.manager.bounds.height : this.position.x | |
}, | |
set(v) { | |
this.position.x = v | |
} | |
}, | |
y: { | |
get() { | |
return config.landscape ? (devicePixelRatio - this.position.x / this.manager.bounds.height) * this.manager.bounds.width : this.position.y | |
}, | |
set(v) { | |
this.position.y = v | |
} | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment