java - 颜色渲染不正确
问题描述
这源于一个问题,许多人从您可以在此处找到的 vanZeben 的游戏引擎教程中得到。问题是 vanZeben 使用的渲染函数。这是非常尴尬和限制。我需要删除它并用呈现精灵表上颜色的代码替换它。
编辑:这是整个项目源代码的链接。
我最接近的是从 int col 初始化中删除颜色 >> 。它仍然会删除所有颜色,除了我在完成教程后添加的瓷砖。
//I know the problem comes from this section of code.
int col = (color >> (sheet.pixels[xSheet + ySheet * sheet.width + tileOffset] * 8) & 255);
if (col < 255)
{
for(int yScale = 0; yScale < scale; yScale++)
{
if (yPixel + yScale < 0 || yPixel + yScale >= height) continue;
for(int xScale = 0; xScale < scale; xScale++)
{
if (xPixel + xScale < 0 || xPixel + xScale >= width) continue;
pixels[(xPixel + xScale) + (yPixel + yScale) * width] = col;
}
}
}
我只需要 col 等于精灵表上像素的颜色。
解决方案
推荐阅读
- javascript - 自定义选择在页面刷新后显示所选值
- android - 滚动视图如何正确适应屏幕
- excel - 具有多个匹配项的 VLOOKUP/MATCH
- three.js - Threejs:阴影显示为盒子形状
- google-cloud-platform - 为什么即使我没有使用 Google Cloud SQL 统计信息也会显示使用情况?
- python - 2020年我们还需要在python包中使用__init__.py吗?
- python - 从另一个文件导入类
- ruby-on-rails - Rails强参数忽略命名参数
- c# - 单元测试,连接到 UWP 中的 api
- python - 如何在 .py 文件 Google Colab 中使用 gpu?