-2
clamp_ip()
을 사용하여 스프라이트를 600 x 315 크기로 유지하려고하지만 작동하지 않는 것 같습니다.클램프()를 사용하여 창 내부에 스프라이트를 유지하십시오.
ship = pygame.image.load("ship.png")
ship_top = screen.get_width() - ship.get_width()
ship_left = screen.get_height()/2 - ship.get_height()/2
while True:
clock.tick(60)
keys = pygame.key.get_pressed()
for event in pygame.event.get():
if event.type == QUIT:
pygame.quit()
sys.exit()
if keys[pygame.K_LEFT]:
ship_left = ship_left - 6
elif keys[pygame.K_RIGHT]:
ship_left = ship_left + 6
screen.blit(back, (x,0))
screen.blit(back2,(x-screenWidth,0))
screen.blit(ship, (ship_top, ship_left))
screen_rect = pygame.Rect((0, 0), (600, 315))
def moveme(ship,ship_top,ship_left):
ship.rect.move_ip((ship_top,ship_left))
ship.rect.clamp_ip(screen_rect)
당신이 작동하지 "무슨 뜻인지 설명해주십시오 :
가 다음 메인 루프에서
Rect
방법을 사용할 수 있습니다 ". ** full ** tracebacks (있는 경우)를 포함하십시오. – VeedracA가 지난 번이 질문을 게시했을 때 답변을 썼지 만 답변을 게시하기 2 초 전에 문자 그대로 삭제했습니다. * 버튼 :-( – sloth