2017-01-10 1 views
1

파이 게임과 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() 

저는 많은 사람들이 파이 게임을 통해 게임을 만들고 완벽하게 작동하는 것으로 보았습니다. 내 코드 또는 내가해야 할 일이 잘못 되었습니까?

답변

1

Android의 pygame_sdl2에는 다른 동작이 있습니다!

screen = pygame.display.set_mode((360,640)) 

(Windows)이 줄은 360x640 크기의 창을 만듭니다.

안드로이드에서 창은 항상 장치 기본 해상도의 전체 화면입니다. 예 : 1080x1920.

Windows에서 블리 팅하려면 360x640 = 230400 픽셀이 필요합니다.

안드로이드 : 1080x1920 = 2073600 픽셀을 그리는은 9 배 더 많습니다.

나는 동일한 문제가 있습니다! 나는 github에 devs 물었다. 그러나 여전히 만족스러운 해결책은 아닙니다. https://github.com/renpy/pygame_sdl2/issues/69

관련 문제