2016-04-12 7 views
0

スプライトは幅が180×高さ90です。ロケットの2つのビューを示しています.1つはエンジンを発射し、もう1つは発射しません。私は、船を1つの角度だけ回転させながら、船の1つのビューだけを表示できるようにする必要があります。どのような角度でも180×90スプライト全体を表示することはできますが、左手または右手のイメージを回転させてブリッティングする前に90x90の矩形にコピーする方法を理解することはできません。ここに私のコードです。 ship_imageは180x90のスプライトで、2つの船を搭載しています。私のtransform.chopは、ship3_imageに1つの船の新しい90x90画像を作成することを目的としています。コードの残りの部分が回転して表示されます。私のスプライトが実際にその中心の周りを回転していることを示しています)。 なぜ、チョップから90 x 90のスプライトが得られないのですか、または90 x 90スプライトを得るためにどのようなコマンドを使用しますか?スプライトの一部をコピーする方法私はPygameで回転する必要があります

ご協力いただきありがとうございます! screen shot of ships rotating

center=(200,200) #Store pos by center 
angle = 0 
while True: 
    ship2_image = ship_image #copy entire 2 ship image 
    ship3_image = pygame.transform.chop(ship2_image,[0,0,90,90])#left hand image 
    ship3_image=pygame.transform.rotate(ship_image,angle) # Rotate whole image 
    size=ship3_image.get_size() #Store size of rotated rect 

    hSize=[n/2 for n in size] #Half the size 
    pos=(center[0]-hSize[0]+200,center[1]-hSize[1]) #Subtract half the size 
    #from the center 
    frame.blit(ship3_image,pos) 
    angle += 1 
    pygame.display.update() 
fpsClock.tick(FPS) 

答えて

0

私の推測:

ship2_image = ship_image.convert() # do this to all images to speed up processing 
ship3_image=pygame.transform.scale(ship_image,(90,90)) # changes the size 
関連する問題