第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

如何使用Pygame圍繞其中心旋轉(zhuǎn)圖像?

如何使用Pygame圍繞其中心旋轉(zhuǎn)圖像?

眼眸繁星 2019-09-06 16:28:53
我一直試圖在使用中圍繞其中心旋轉(zhuǎn)圖像,pygame.transform.rotate()但它不起作用。特別是掛起的部分是rot_image = rot_image.subsurface(rot_rect).copy()。我得到了例外:ValueError: subsurface rectangle outside surface area以下是用于旋轉(zhuǎn)圖像的代碼:def rot_center(image, angle):    """rotate an image while keeping its center and size"""    orig_rect = image.get_rect()    rot_image = pygame.transform.rotate(image, angle)    rot_rect = orig_rect.copy()    rot_rect.center = rot_image.get_rect().center    rot_image = rot_image.subsurface(rot_rect).copy()    return rot_image
查看完整描述

3 回答

?
慕姐8265434

TA貢獻(xiàn)1813條經(jīng)驗(yàn) 獲得超2個(gè)贊

您正在刪除旋轉(zhuǎn)創(chuàng)建的矩形。您需要保留rect,因?yàn)樗谛D(zhuǎn)時(shí)會(huì)改變大小。


如果要保留對(duì)象位置,請(qǐng)執(zhí)行以下操作:

def rot_center(image, angle):

    """rotate a Surface, maintaining position."""


    loc = image.get_rect().center  #rot_image is not defined 

    rot_sprite = pygame.transform.rotate(image, angle)

    rot_sprite.get_rect().center = loc

    return rot_sprite


    # or return tuple: (Surface, Rect)

    # return rot_sprite, rot_sprite.get_rect()


查看完整回答
反對(duì) 回復(fù) 2019-09-06
  • 3 回答
  • 0 關(guān)注
  • 4955 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)