【发布时间】:2016-05-16 22:25:41
【问题描述】:
var ctx = space.getContext("2d");
var FPS = 40;
var score = 0;
function scoring(){
ctx.font = "20px Helvetica";
ctx.fillStyle = "#001e52";
if(score<10){
ctx.fillText(score, center.x+44.5, center.y+57);
}
if(score>=10 && score<=99){
ctx.fillText(score, center.x+38.9, center.y+57);
}
if(score>=100 && score<=999){
ctx.fillText(score, center.x+33, center.y+57);
}
if(score>=1000){
score=0;
}
}
setInterval(scoring, 1000/FPS);
上面的代码正在处理我制作的另一个画布游戏,完全按照展示的方式制作。现在我将它复制并粘贴到我的新游戏中,但它不起作用(我显然更改了坐标和所有内容以适应我的新游戏)。在 Chrome 上检查元素时,它给了我这个奇怪的错误:Uncaught TypeError: ctx.fillText is not a function有什么想法会发生什么吗?
【问题讨论】:
标签: javascript canvas typeerror