简体   繁体   English

如何在 javascript html 游戏中使文本更大?

[英]How do I make text bigger in a javascript html game?

In my high school game design class we are making javascript games as HTML files and we are making brick break right now, and I am trying to make my text on the screen bigger and I cant figure out how to do it.在我的高中游戏设计课上,我们正在将 javascript 游戏制作为 HTML 文件,我们现在正在打破砖块,我试图使屏幕上的文本更大,但我不知道该怎么做。

this is what I have now for writing text on the screen这就是我现在在屏幕上写文本的方法

canvasContext.fillText("SAMPLE TEXT GOES HERE ", 350, 100);

and the text is really small.而且文字真的很小。 I'd like for it to be bigger.我想让它更大。 how do i do that?我怎么做?

Something like this?像这样的东西?

canvasContext.font = "20px Georgia";
canvasContext.fillText("SAMPLE TEXT GOES HERE ", 350, 100);

Add canvasContext.font = "30px Verdana"添加canvasContext.font = "30px Verdana"

30px is the font size and verdana is the font family. 30px 是字体大小, verdana是字体系列。

我期待更多细节,但您可以像这样重新生成文本:

canvasContent.fillText("SAMPLE TEXT GOES HERE ", 435, 10);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM