Есть ли у кого-нибудь идея, почему это необходимо или я делаю что-то не так, из-за чего это необходимо.
Код: Выделить всё
#include "game.h"
/**
* DONT FORGET TO CHANGE THE USER_SETUP.H IN THE TFT_eSPI lib
*/
void Game::Init()
{
// Start the tft display and set it to black
tft.init();
tft.setRotation(1); //This is the display in landscape
tft.setSwapBytes(true);
// Clear the screen before writing to it
tft.fillScreen(TFT_BLACK);
}
float x = 50;
float y = 50;
void Game::Loop()
{
background.createSprite(screenWidth, screenHeight);
background.setSwapBytes(true); // Correct color
background.setColorDepth(8);
background.pushImage(0, 0, screenWidth, screenHeight, backgroundSprite);
cursor.createSprite(16,16);
cursor.setColorDepth(8);
cursor.pushImage(0, 0, 16, 16, cursorSprite);
cursor.pushToSprite(&background, x, y, TFT_BLACK);
background.pushSprite(0,0);
x++;
y++;
if (x > screenWidth) {
x = 0;
}
if (y > screenHeight) {
y = 0;
}
}
Код: Выделить всё
#ifndef GAME_H
#define GAME_H
#include "Arduino.h"
#include
#include "sprites/cursor.h"
#include "sprites/background.h"
class Game
{
public:
void Init();
void Loop();
private:
TFT_eSPI tft = TFT_eSPI();
TFT_eSprite cursor = TFT_eSprite(&tft);
TFT_eSprite background = TFT_eSprite(&tft);
TFT_eSprite gyroText = TFT_eSprite(&tft);
float screenWidth = 320;
float screenHeight = 240;
};
#endif
Код: Выделить всё
background.createSprite(screenWidth, screenHeight);
background.setSwapBytes(true); // Correct color
background.setColorDepth(8);
Код: Выделить всё
cursor.createSprite(16,16);
cursor.setColorDepth(8);
Подробнее здесь: https://stackoverflow.com/questions/790 ... s-expected