【发布时间】:2017-11-24 23:15:03
【问题描述】:
这是我第一次尝试将 libgdx 游戏部署到 html,但遇到了一些困难。
在桌面上一切正常,但在浏览器中我的两个精灵没有出现,其余的都很好。
这两个精灵应该是背景和滚动角色移动的原因。
我在 GameScree 类的 show 方法中加载我的纹理,如下所示:
backgroundTexture = new Texture(Gdx.files.internal("background.png"));
//setting wraping to repeat to achive scrolling background by one texture
backgroundTexture.setWrap(Texture.TextureWrap.Repeat, Texture.TextureWrap.Repeat);
//and I render it like this (I create a Sprite of it)
batch.draw(backgroundSprite.getTexture(),0,0, (int) position ,0, 1280, 720);
通过增加位置,背景正在滚动,这在桌面上可以正常工作。
我在 chrome 控制台中遇到错误:
[.Offscreen-For-WebGL-00000000071AC350]渲染警告:绑定到纹理单元 0 的纹理不可渲染。它可能不是 2 的幂并且具有不兼容的纹理过滤。
我不完全理解为什么,它是如何不兼容的?而且,我的纹理都不是 POT,但它们仍在工作。
【问题讨论】: