mirror of
https://github.com/yuukiwww/taiko-web.git
synced 2024-10-22 17:05:49 +02:00
View: Fix touch
This commit is contained in:
parent
2e00290af4
commit
1356f682cc
@ -81,7 +81,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(!this.multiplayer){
|
if(!this.multiplayer){
|
||||||
pageEvents.add(this.canvas, ["mousedown", "touchstart"], this.onmousedown.bind(this))
|
pageEvents.add(this.canvas, "mousedown", this.onmousedown.bind(this))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
run(){
|
run(){
|
||||||
@ -1356,27 +1356,35 @@
|
|||||||
ontouch(event){
|
ontouch(event){
|
||||||
for(let touch of event.changedTouches){
|
for(let touch of event.changedTouches){
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
var pageX = touch.pageX * this.pixelRatio
|
if(this.controller.game.paused){
|
||||||
var pageY = touch.pageY * this.pixelRatio
|
var mouse = this.mouseOffset(event.touches[0].pageX, event.touches[0].pageY)
|
||||||
|
var moveTo = this.pauseMouse(mouse.x, mouse.y)
|
||||||
var c = this.touchCircle
|
if(moveTo !== null){
|
||||||
var pi = Math.PI
|
this.pauseConfirm(moveTo)
|
||||||
var inPath = () => this.ctx.isPointInPath(pageX, pageY)
|
|
||||||
|
|
||||||
this.ctx.beginPath()
|
|
||||||
this.ctx.ellipse(c.x, c.y, c.rx, c.ry, 0, pi, 0)
|
|
||||||
|
|
||||||
if(inPath()){
|
|
||||||
if(pageX < this.winW / 2){
|
|
||||||
this.touchNote("don_l")
|
|
||||||
}else{
|
|
||||||
this.touchNote("don_r")
|
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
if(pageX < this.winW / 2){
|
var pageX = touch.pageX * this.pixelRatio
|
||||||
this.touchNote("ka_l")
|
var pageY = touch.pageY * this.pixelRatio
|
||||||
|
|
||||||
|
var c = this.touchCircle
|
||||||
|
var pi = Math.PI
|
||||||
|
var inPath = () => this.ctx.isPointInPath(pageX, pageY)
|
||||||
|
|
||||||
|
this.ctx.beginPath()
|
||||||
|
this.ctx.ellipse(c.x, c.y, c.rx, c.ry, 0, pi, 0)
|
||||||
|
|
||||||
|
if(inPath()){
|
||||||
|
if(pageX < this.winW / 2){
|
||||||
|
this.touchNote("don_l")
|
||||||
|
}else{
|
||||||
|
this.touchNote("don_r")
|
||||||
|
}
|
||||||
}else{
|
}else{
|
||||||
this.touchNote("ka_r")
|
if(pageX < this.winW / 2){
|
||||||
|
this.touchNote("ka_l")
|
||||||
|
}else{
|
||||||
|
this.touchNote("ka_r")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1418,15 +1426,10 @@
|
|||||||
}
|
}
|
||||||
onmousedown(event){
|
onmousedown(event){
|
||||||
if(this.controller.game.paused){
|
if(this.controller.game.paused){
|
||||||
if(event.type === "mousedown"){
|
if(event.which !== 1){
|
||||||
if(event.which !== 1){
|
return
|
||||||
return
|
|
||||||
}
|
|
||||||
var mouse = this.mouseOffset(event.offsetX, event.offsetY)
|
|
||||||
}else{
|
|
||||||
event.preventDefault()
|
|
||||||
var mouse = this.mouseOffset(event.touches[0].pageX, event.touches[0].pageY)
|
|
||||||
}
|
}
|
||||||
|
var mouse = this.mouseOffset(event.offsetX, event.offsetY)
|
||||||
var moveTo = this.pauseMouse(mouse.x, mouse.y)
|
var moveTo = this.pauseMouse(mouse.x, mouse.y)
|
||||||
if(moveTo !== null){
|
if(moveTo !== null){
|
||||||
this.pauseConfirm(moveTo)
|
this.pauseConfirm(moveTo)
|
||||||
@ -1518,7 +1521,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(!this.multiplayer){
|
if(!this.multiplayer){
|
||||||
pageEvents.remove(this.canvas, ["mousedown", "touchstart"])
|
pageEvents.remove(this.canvas, "mousedown")
|
||||||
}
|
}
|
||||||
pageEvents.mouseRemove(this)
|
pageEvents.mouseRemove(this)
|
||||||
delete this.pauseMenu
|
delete this.pauseMenu
|
||||||
|
Loading…
Reference in New Issue
Block a user