2016-03-20 67 views
0

を変更しません:は<a href="http://www.pygame.org/docs/ref/rect.html" rel="nofollow">documentation</a>から何か

「サイズ、幅または高さに割り当てるには、長方形の大きさを変更します」。 私は次のサークルを持っていますが、新しい属性を割り当てますが、サークルに変更は見られません。何が間違っているのですか?

import pygame 
from pygame.locals import * 

pygame.init() 

TV=pygame.display.set_mode((400,400)) 
pygame.display.set_caption("Rect") 

c=pygame.draw.circle(TV,(0,100,0),(150,150),100,1) 
pygame.draw.rect(TV,(100,0,0),c,1) 
print c.size 
c.size=(100,100) 
print c.size 
pygame.display.flip() 

while True: 
    for e in pygame.event.get(): 
     if e.type==QUIT: 
      pygame.quit() 

答えて

0

サークルを画面上に描画します。

機能が変更された画素の境界領域を表す矩形を返す:すべての描画関数は、Rectbut返します。

実際に画面上の円を変更するには、最初に消去してから(上に描画する)、必要なサイズで新しい円を描画する必要があります。ここで

は簡単な例です:

import pygame 
from pygame.locals import * 

pygame.init() 

pygame.display.set_caption("Rect") 

TV = pygame.display.set_mode((400,400)) 
c = pygame.draw.circle(TV, (0, 100, 0), TV.get_rect().center, 100, 1) 
clock = pygame.time.Clock() 
pygame.time.set_timer(USEREVENT, 250) 
value = 10 
run = True 
while run: 
    for e in pygame.event.get(): 
     if e.type == QUIT: 
      run = False 
     if e.type == USEREVENT: 
      c.inflate_ip(value, value) 
      if c.width > 260 or c.width < 200: 
       value *= -1 

    TV.fill(pygame.color.Color('Black')) 
    pygame.draw.circle(TV, (0, 100, 0), c.center, c.width/2, 1) 
    pygame.display.flip() 
    clock.tick(60) 
pygame.quit()  
関連する問題