所以我這里有這把槍,它朝我的鼠標 x 和鼠標 y 位置旋轉,但問題(視頻)是槍倒置了。有沒有辦法讓我的槍的圖像不倒置,并做與我的槍朝向右側相同的運動?就像左側的槍由于某種原因倒置了,我根本不知道該怎么做槍支圖片:my gun draw(self) def draw(self,drawX,drawY): self.rect.topleft = (drawX,drawY) # the gun's hitbox # rotating the gun dx = self.look_at_pos[0] - self.rect.centerx dy = self.look_at_pos[1] - self.rect.centery angle = (180/math.pi) * math.atan2(-dy, dx) gun_size = self.image.get_size() pivot = (8, gun_size[1]//2) blitRotate(window, self.image, self.rect.center, pivot, angle) def lookAt( self, coordinate ): self.look_at_pos = coordinate我的全槍課class handgun(): def __init__(self,x,y,height,width,color): self.x = x self.y = y self.height = height self.width = width self.color = color self.rect = pygame.Rect(x,y,height,width) # LOL THESE IS THE HAND self.shootsright = pygame.image.load("hands.png") self.image = self.shootsright self.rect = self.image.get_rect(center = (self.x, self.y)) self.look_at_pos = (self.x, self.y) self.isLookingAtPlayer = False self.look_at_pos = (x,y) self.hitbox = (self.x + -18, self.y, 46,60) def draw(self,drawX,drawY): self.rect.topleft = (drawX,drawY) # the gun's hitbox # rotating the gun dx = self.look_at_pos[0] - self.rect.centerx dy = self.look_at_pos[1] - self.rect.centery angle = (180/math.pi) * math.atan2(-dy, dx) gun_size = self.image.get_size() pivot = (8, gun_size[1]//2) blitRotate(window, self.image, self.rect.center, pivot, angle) def lookAt( self, coordinate ): self.look_at_pos = coordinate我的完整代碼:感謝腳本 安迪的幫助謝謝!
添加回答
舉報
0/150
提交
取消