5

我开始探索 Python 和 Pygame,但是我遇到了一个问题。我在屏幕上绘制的所有内容都只显示在窗口的左上角。我以为这是我的代码,但我尝试过的任何演示程序也以相同的方式显示。

youtube 上来自 thenewboston 的演示代码

import pygame, sys
from pygame.locals import *

pygame.init()

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

background = pygame.image.load("Background.jpg").convert()
mouse_c = pygame.image.load("ball.png").convert_alpha()

while True:
    for event in pygame.event.get():
        if event.type == QUIT:
            pygame.quit()
            sys.exit()

    screen.blit(background, (0,0))

    x,y = pygame.mouse.get_pos()
    x -= mouse_c.get_width()/2
    y -= mouse_c.get_height()/2

    screen.blit(mouse_c, (x,y))

    pygame.display.update()

在视频中他的显示正确,我的看起来像这样 仅在屏幕左上角四分之一的游戏渲染截图

使用:

  • Python 2.7.4 32 位
  • pygame 1.9.1 32 位
  • macbook pro 视网膜上的 mac 10.8.3 64 位

我认为要么与视网膜显示器有关,要么我安装了错误的东西。任何帮助,将不胜感激。

4

1 回答 1

6

事实上,问题在于视网膜屏幕的分辨率。为了让 pygame 正常工作,请下载 setresx 并使用它将您的分辨率设置为没有 HiDPI 的任何设置。

于 2013-06-23T05:29:28.550 回答