首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Ursina引擎纹理

Ursina引擎纹理
EN

Stack Overflow用户
提问于 2021-11-23 17:22:57
回答 3查看 218关注 0票数 2

因此,我开始使用python的API,名为Ursina Engine,我需要添加一个纹理。无论我为文件路径设置什么,总是不会渲染。没有错误,只是一个空白的实体。

代码语言:javascript
复制
    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()   
EN

回答 3

Stack Overflow用户

发布于 2021-11-27 10:59:59

你的代码应该可以工作,但是如果它不能工作,你可能没有正确加载纹理。例如,如果它位于一个名为'textures‘的文件中,你的代码应该是这样的:

代码语言:javascript
复制
sans_texture = load_texture('textures/sans.png')
sand = Entity(model = 'quad', texture = sans_texture)

但是如果它仍然不起作用,你可以试试这个:

代码语言:javascript
复制
sand = Entity(model = 'quad', texture = 'textures/sans.png')

我希望这能对你有所帮助。

票数 2
EN

Stack Overflow用户

发布于 2021-11-28 14:32:36

可能纹理加载不正确,要正确加载它,可以尝试复制粘贴图像链接,例如:

代码语言:javascript
复制
sand = Entity(model = 'quad', texture = 'C:/Users/guest/Pictures/sans.png')
票数 1
EN

Stack Overflow用户

发布于 2021-12-31 16:43:37

就这么做吧:

代码语言:javascript
复制
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()   
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/70085193

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档