c++ - 使用 eSprite 在 TFT 上移动元素
问题描述
我开始将TFT_eSPI用于我的一个 ESP32 项目。我对这个库没有太多经验,但希望使用在背景图像上浮动/移动绘制几个元素(如实心圆圈)(不弄乱背景)我尝试使用 TFT_eSprite 作为前景并推动它们,但注意到它在背景上留下痕迹。
TFT_eSPI tft = TFT_eSPI();
TFT_eSprite img = TFT_eSprite(&tft);
void drawCirle(int x, int y)
{
img.setColorDepth(8);
img.createSprite(36, 36);
img.fillSprite(TFT_TRANSPARENT);
img.fillCircle(18, 18, 8, TFT_BLUE);
img.pushSprite(x, y, TFT_TRANSPARENT);
img.deleteSprite();
}
int y, x = 8;
void setup()
{
tft.init();
tft.setRotation(0);
tft.fillScreen(TFT_RED); // let say that's the background
}
void loop()
{
drawCirle(x, y++); // this is forground
if (y > 240)
{
y = 0;
x += 16;
}
delay(100);
}
有没有更好的方法来处理这个问题?
解决方案
推荐阅读
- swift - AvAudioEngine 可以播放和录音吗?
- javascript - 如何在 React JS 中像普通 Javascript 一样替换或删除字符串中的字符?
- unity3d - 参数值未从脚本发送到混合树(Unity 2020)
- typescript - 我在哪里可以获得 VpcLink ID?
- html - CSS 高度不是 100% 并且页脚不粘在底部:0;在移动设备上时
- pandas - 可以从 pandas.core.groupby.generic.SeriesGroupBy 对象访问/检索索引名称吗?
- docker - 使用 Docker 进行弹性搜索
- networking - 将 Discord.js v11 模块转换为 v12?
- azure - 依赖于暂存槽,资源 id 中有多个逗号
- arrays - 打印给定字符串中以 1 开头和结尾的子字符串的数量