-1
클릭 한 이미지를 감지하는 방법이나 ID를 추가하는 방법은 내가 볼 수있는 모든 예제가 있는데, 나는 운이없는 것으로 검색했다.파이 게임에서 같은 속성을 가진 많은 인스턴스를 만드는 방법
import pygame , random
from pygame.locals import *
pygame.init()
screen = pygame.display.set_mode((800,600),16)
screen.fill((60,120,160))
instances = 10
while instances > 0:
image = pygame.image.load("image.png").convert()
image_rect = image.get_rect()
image_rect[0] = random.randint(10,700)
image_rect[1] = random.randint(10,500)
screen.blit(image,image_rect)
instances -= 1
pygame.display.update()
while True:
for event in pygame.event.get():
if event.type == QUIT:
exit()
elif event.type == pygame.MOUSEBUTTONDOWN:
if event.button == 1:
if image_rect.collidepoint(event.pos):
print "image 1 clicked"
목록을 사용하십시오. 그런 식으로 루프하면 덮어 씁니다. – aIKid