かなりの数のチュートリアルをオンラインで見ましたが、表面に半透明の赤い円を描くことができないようです。
このメソッドを使用して、半透明の赤い円でスプライトを強調表示したい:
def highlight(self):
s = pygame.Surface((self.rect[2]*2,self.rect[3]*2)) #create a surface to draw circle on twice as big as the sprite rectangle)
s.fill((0,0,0)) #fills the surface with black
pygame.draw.circle(s, (255,0,0), self.rect.center, self.rect[3], 0) # draws red circle on the surface
s.set_colorkey((0,0,0)) # makes the black surface background transparent
s.set_alpha(50) # makes the whole surface translucent (i.e. the red circle remaining)
variables.screen.blit(s, (self.rect[0]-self.rect[2]/2,self.rect[1]-self.rect[3]/2)) #blit's the red circle centered on my sprite.
何が間違っているのか本当にわかりません...次を使用するだけで、赤い円を問題なく表示できます。
def highlight(self):
pygame.draw.circle(DISPLAYSURF, (255,0,0), self.rect.center, self.rect[3], 0) # with display surf as my background for the whole game
でも半透明には出来ません。また、gfxdraw は将来の Pygame バージョンではサポートされない可能性があるため、使用することに消極的です。
ご協力ありがとうございました。