Merge pull request #80 from LoveEevee/view-add-song-bg

SongBg: Reduce background resolution on mobile
This commit is contained in:
Bui 2018-11-24 19:06:22 +00:00 committed by GitHub
commit 8af11bfd69
4 changed files with 29 additions and 5 deletions

View File

@ -22,7 +22,8 @@
} }
#song-stage{ #song-stage{
height: calc(44 / 720 * 100vh); height: calc(44 / 720 * 100vh);
background-position: center; background-position: center bottom;
background-repeat-y: no-repeat;
} }
.portrait #songbg{ .portrait #songbg{
height: 63.4%; height: 63.4%;

View File

@ -350,6 +350,8 @@ class Game{
this.mainMusicPlaying = false this.mainMusicPlaying = false
this.view.pauseMove(0, true) this.view.pauseMove(0, true)
this.view.gameDiv.classList.add("game-paused") this.view.gameDiv.classList.add("game-paused")
this.view.lastMousemove = this.view.getMS()
this.view.cursorHidden = false
}else{ }else{
assets.sounds["cancel"].play() assets.sounds["cancel"].play()
this.paused = false this.paused = false
@ -357,6 +359,7 @@ class Game{
this.startDate += currentDate - this.latestDate this.startDate += currentDate - this.latestDate
this.sndTime = currentDate - snd.buffer.getTime() * 1000 this.sndTime = currentDate - snd.buffer.getTime() * 1000
this.view.gameDiv.classList.remove("game-paused") this.view.gameDiv.classList.remove("game-paused")
this.view.pointer()
} }
} }
isPaused(){ isPaused(){

View File

@ -63,11 +63,31 @@ class loadSong{
let filenameAb = filename + (i === 0 ? "a" : "b") let filenameAb = filename + (i === 0 ? "a" : "b")
let img = document.createElement("img") let img = document.createElement("img")
promises.push(pageEvents.load(img).then(() => { promises.push(pageEvents.load(img).then(() => {
if(this.touchEnabled){
return new Promise((resolve, reject) => {
var canvas = document.createElement("canvas")
var w = Math.floor(img.width / 2)
var h = Math.floor(img.height / 2)
canvas.width = w
canvas.height = h
var ctx = canvas.getContext("2d")
ctx.drawImage(img, 0, 0, w, h)
canvas.toBlob(blob => {
let img2 = document.createElement("img")
pageEvents.load(img2).then(() => {
assets.image[filenameAb] = img2
resolve()
}, reject)
img2.src = URL.createObjectURL(blob)
})
})
}else{
assets.image[filenameAb] = img assets.image[filenameAb] = img
}
})) }))
img.src = gameConfig.assets_baseurl + "img/" + filenameAb + ".png" img.src = gameConfig.assets_baseurl + "img/" + filenameAb + ".png"
} }
return Promise.all(promises).then(resolve, reject) Promise.all(promises).then(resolve, reject)
} }
}) })
} }

View File

@ -1523,7 +1523,7 @@
} }
} }
onmousemove(event){ onmousemove(event){
this.lastMousemove = this.controller.getElapsedTime() this.lastMousemove = this.getMS()
this.cursorHidden = false this.cursorHidden = false
if(!this.multiplayer && this.controller.game.paused){ if(!this.multiplayer && this.controller.game.paused){
@ -1568,7 +1568,7 @@
mouseIdle(){ mouseIdle(){
var lastMouse = pageEvents.getMouse() var lastMouse = pageEvents.getMouse()
if(lastMouse && !this.cursorHidden){ if(lastMouse && !this.cursorHidden){
if(this.controller.getElapsedTime() >= this.lastMousemove + 2000){ if(this.getMS() >= this.lastMousemove + 2000){
this.cursor.style.top = lastMouse.clientY + "px" this.cursor.style.top = lastMouse.clientY + "px"
this.cursor.style.left = lastMouse.clientX + "px" this.cursor.style.left = lastMouse.clientX + "px"
this.cursor.style.pointerEvents = "auto" this.cursor.style.pointerEvents = "auto"