You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

游戏运行时纹理遮罩功能不符合预期问题求助

运行时动态遮罩实现问题

我正在开发一款游戏,需要遮挡背景大部分区域,仅显示玩家周围及1-2块高亮区域,因此纹理遮罩必须在运行时实现(而非游戏启动前预制作或使用现成PNG文件)。

游戏主类代码

protected Pixmap circleShadowBigPixmap;
protected Pixmap pixmapBlackCover;
protected Texture pixmapTexture;

Update方法代码

arrowGame.lightX++;
arrowGame.pixmapBlackCover.setBlending(Pixmap.Blending.None); // 开始绘制像素前设置
arrowGame.pixmapBlackCover.drawPixmap(arrowGame.circleShadowBigPixmap, arrowGame.lightX, 500);
arrowGame.pixmapBlackCover.setBlending(Pixmap.Blending.SourceOver);
arrowGame.pixmapTexture.draw(arrowGame.pixmapBlackCover, 0, 0);

绘制类代码

sb.draw(arrowGame.pixmapTexture, x, y); // sb - spritebatch(精灵批处理对象)

图形准备类代码

arrowGame.circleShadowBig = new Texture("shadowCircleBig.png");
arrowGame.circleShadowBig.getTextureData().prepare();

截图说明

  • 1- 异常遮罩片段(该区域不应影响源Pixmap,既不应为黑色也不应透明)
  • 2- 透明区域
  • 3- 黑色遮挡区域

相关截图

带遮罩的纹理
遮罩纹理

内容的提问来源于stack exchange,提问作者Radek0582

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.14 06:03:11