我正在尝试使用pygame和pyscroll构建一个小型游戏。我想在对话框窗口中显示文本。我的问题是,当我在默认地图上执行此操作时,文本全部模糊,因为我将地图缩放至2.5倍。因此,我尝试使用1倍缩放功能在普通地图上制作一个额外的透明地图,以使文本看起来正常。但是我没有使其正常工作,我觉得有一种更简单的方法可以完成我想做的事情。
有人知道我应该怎么做吗?
以下是加载地图的代码:
from os import path
import pygame as pg
import pytmx
from game_settings import *
import game_sprites
from pytmx.util_pygame import load_pygame
import pyscroll
from pyscroll.group import PyscrollGroup
def load_map(game, map_name):
""" Function to load a selected map and assets of the map """
game.screen.fill(BLACK)
tmx_data = load_pygame(path.join(game.map_folder, map_name))
empty_data = load_pygame(path.join(game.map_folder, "empty.tmx"))
print ("map loaded")
game.walls.empty()
for tile_object in tmx_data.objects:
# print tile_object.id
if tile_object.name == 'wall' or tile_object.name == 'door' or tile_object.name == 'sign':
game_sprites.Obstacle(game, tile_object.x, tile_object.y,
tile_object.width, tile_object.height, tile_object.name, tile_object.id)
# print tile_object.name, tile_object.id
#print(obsacle_object)
map_data = pyscroll.data.TiledMapData(tmx_data)
map_empty =pyscroll.data.TiledMapData(empty_data)
map_layer = pyscroll.BufferedRenderer(map_data, pg.display.get_surface().get_size(), clamp_camera=True, tall_sprites=1)
map_layer.zoom = 2.5
map_overlayer = pyscroll.BufferedRenderer(map_empty, game.dialog_window.image.get_size(), clamp_camera=True,
tall_sprites=1)
map_overlayer.zoom = 1
group = PyscrollGroup(map_layer=map_layer, default_layer=1)
overlay_group = PyscrollGroup(map_layer=map_overlayer, default_layer=3)
return (group, overlay_group, map_layer)