因此,我开始使用python的API,名为Ursina Engine,我需要添加一个纹理。无论我为文件路径设置什么,总是不会渲染。没有错误,只是一个空白的实体。
from ursina import * # import everything we need with one line.
#an entity is basically anything you can see or hear/interact on a screen
def update():#updtes every frame
if held_keys['a']:
test_square.x -= 1 * time.dt #so the .x is the axis (you can use y too and -= minuses every frame), multiplying it by time.delta means it will move in accordance with the framerate
# time.dt is the completion time between the last frame
if held_keys['d']:
test_square.x += 1 * time.dt
app = Ursina()
test_square = Entity(model = 'quad', color = color.red, scale = (1,4), position = (3,1))#x then y for scale and pos
sans_texture = load_texture('sans.png')
sand = Entity(model = 'quad', texture = sans_texture)
app.run() 发布于 2021-11-27 10:59:59
你的代码应该可以工作,但是如果它不能工作,你可能没有正确加载纹理。例如,如果它位于一个名为'textures‘的文件中,你的代码应该是这样的:
sans_texture = load_texture('textures/sans.png')
sand = Entity(model = 'quad', texture = sans_texture)但是如果它仍然不起作用,你可以试试这个:
sand = Entity(model = 'quad', texture = 'textures/sans.png')我希望这能对你有所帮助。
发布于 2021-11-28 14:32:36
可能纹理加载不正确,要正确加载它,可以尝试复制粘贴图像链接,例如:
sand = Entity(model = 'quad', texture = 'C:/Users/guest/Pictures/sans.png')发布于 2021-12-31 16:43:37
就这么做吧:
from ursina import * # import everything we need with one line.
#an entity is basically anything you can see or hear/interact on a screen
def update():#updtes every frame
if held_keys['a']:
test_square.x -= 1 * time.dt #so the .x is the axis (you can use y too and -= minuses every frame), multiplying it by time.delta means it will move in accordance with the framerate
# time.dt is the completion time between the last frame
if held_keys['d']:
test_square.x += 1 * time.dt
app = Ursina()
test_square = Entity(model = 'quad', color = color.red, scale = (1,4), position = (3,1))#x then y for scale and pos
sand = Entity(model = 'quad', texture = 'sans.png')
app.run() https://stackoverflow.com/questions/70085193
复制相似问题