1 Star 0 Fork 0

余赟昊 / Flappy-polimin

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
ScoreManager.js 992 Bytes
一键复制 编辑 原始数据 按行查看 历史
余赟昊 提交于 2020-11-16 20:57 . 我修复了不能连点的bug
class ScoreManager{
constructor(){
this.score = 0;
}
update(){
}
render(){
let numLength = this.score.toString().length;
// console.log(numLength);
let beginX = 0;
//判断位数是奇数还是偶数
if((numLength & 1) === 0){
//偶数
beginX = game.canvas.width / 2 - numLength / 2 * 48;
// console.log(beginX);
}else if((numLength & 1) === 1){
//奇数
beginX = game.canvas.width / 2 - numLength / 2 * 48;
}
for(let i = 0; i < numLength; ++i){
let curNum = parseInt(this.score.toString().substr(i,1));
this.renderOneScore(curNum, beginX + i * 48, 100)
}
}
renderOneScore(score, x, y){
// game.pen.drawImage(game.images.score,this.score*48,0,38,50,game.canvas.width/2-20,game.canvas.height/2-20,45,50)
game.pen.drawImage(game.images.score,score*48,0,38,50,x,y,45,50)
}
}
1
https://gitee.com/yu_yunhao/flappy-polimin.git
git@gitee.com:yu_yunhao/flappy-polimin.git
yu_yunhao
flappy-polimin
Flappy-polimin
master

搜索帮助