파이 게임과 pygame_sdl2를 사용하여 안드로이드 용 게임을 만든 다음 pgs4a를 사용하여 apk로 컴파일하려고합니다.파이 게임이 안드로이드에서 블리치 이미지를 매우 느리게하고 있습니다.
나는 처음에는 배경으로 .fill()
을 사용하고 정상적으로 작동하지만 이미지를 배경으로 blit하려 할 때 내 프로그램이 실제로 휴대 전화에서 느려지 게되었습니다. 모든 것은 PC에서 잘 작동합니다.
여기 내 코드입니다.
손가락의 위치를 표시하고 화면에 터치 한 횟수를 세면됩니다.
import pygame_sdl2
pygame_sdl2.import_as_pygame()
import pygame
import os
def main():
pygame.init()
screen = pygame.display.set_mode((360,640))
sleeping = False
running = True
clock = pygame.time.Clock()
font = pygame.font.Font("data/DejaVuSans.ttf", 48)
background = pygame.image.load("image/background.jpg").convert()
background = pygame.transform.scale(background, (screen.get_width(),screen.get_width()))
press = 0
while running:
clock.tick(60)
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
elif event.type == pygame.KEYDOWN and event.key == pygame.K_ESCAPE:
running = False
elif event.type == pygame.KEYDOWN and event.key == pygame.K_AC_BACK:
running = False
elif event.type == pygame.APP_WILLENTERBACKGROUND:
sleeping = True
elif event.type == pygame.APP_DIDENTERFOREGROUND:
sleeping = False
screen = pygame.display.set_mode((360,640))
elif event.type == pygame.FINGERDOWN:
press += 1
if not sleeping:
x, y = pygame.mouse.get_pos()
screen.blit(background, (0.5*(screen.get_width()-background.get_width()),0.5*(screen.get_height()-background.get_height())))
text = font.render(str((x,y,press)), True, (255,255,255))
screen.blit(text, (0.5*(screen.get_width()-text.get_width()),0.5*(screen.get_height()-text.get_height())))
pygame.display.flip()
if __name__ == "__main__":
main()
저는 많은 사람들이 파이 게임을 통해 게임을 만들고 완벽하게 작동하는 것으로 보았습니다. 내 코드 또는 내가해야 할 일이 잘못 되었습니까?