I am fairly new to pygame and am working on my first game. (So sorry if I m asking a stupid question) I am trying to get the title of the game to slowly increase and decrease in size like a sort of breathing effect in order to make the home screen more visually appealing.
这里,我已想到的是,要输入形象:
name = self.dir_path + "pixeltitle.png"
self.pixeltitle = pg.image.load(name)
self.pixeltitlerect = self.pixeltitle.get_rect()
self.pixeltitlerect.center = (250,120)
self.screen.blit(self.pixeltitle,self.pixeltitlerect)
我先看一看一眼,我会增加休养的体积,然而,它却被转移到右上下。 是否有办法增加面积,并在同一地点保留中心? 是否有办法使增减规模更加顺利? 该法典的其余部分:
clicked = False
grow = 0
mode = grow
while not clicked:
if grow>40:
mode = shrink
if grow<1:
mode = grow
self.pixeltitle = pg.transform.scale(self.pixeltitle,(400,400))
if mode == grow :
grow+=1
else:
grow-=1
xsize=400+int(grow)
ysize=400+int(grow)
self.pixeltitle = pg.transform.scale(self.pixeltitle,(xsize,ysize))
self.pixeltitlerect.center = (250,120)
self.screen.blit(self.pixeltitle,self.pixeltitlerect)
pg.display.flip()