我正在使用的IDE(pyscripter)有一些字体错误,所以我尝试使用自己的字体。 我很难把信放在我想要的地方。例如
draw_word('abab',[15,10])
使“abab”这个词(到目前为止我只做了a和b)。但是,如果我要这样做:
draw_word('abab',[50,10])
然后这些信就散开了。我想让这个词以x=50的速度出现在屏幕上。你知道吗
draw_word('abab',[5,10])
这会将单词向上压缩,而不是在x=5时将其放到屏幕上。你知道吗
我该如何解决这个问题?是什么导致了这个问题?你知道吗
完整代码为:
draw_word('abab',[15,10])
这就叫:
def draw_word(word,xy):
loc=1 # short for location
for letter in word:
draw_letter(letter,[(xy[0]*loc),xy[1]]) #uses loc to move the letter over
loc+=1 #next letter
这就叫:
def draw_letter(letter,xy):
l=pygame.image.load(('letters/'+letter+'.png')).convert()
l.set_colorkey(WHITE)
screen.blit(l,xy)
在
for letter in word
中加上print xy[0]*loc
,你就会明白为什么字母放错了地方。你知道吗例如
x=50
:第一个字母50*1=50,下一个字母50*2=100,下一个字母50*3=150您需要:
使用
loc += 20
中的其他值可以获得更好的字母间距。你知道吗顺便说一句:你可以这样写:
现在你可以用了
相关问题 更多 >
编程相关推荐