Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New feature request for Sprite handling called "created" #682

Closed
toetoast opened this issue Jul 5, 2020 · 1 comment
Closed

New feature request for Sprite handling called "created" #682

toetoast opened this issue Jul 5, 2020 · 1 comment

Comments

@toetoast
Copy link

toetoast commented Jul 5, 2020

Hi, this is not an issue but more of an enhancement for consideration.

I've been using the following new Method (called "created") for the TFT_eSprite Class, that I think others may find useful:

/***************************************************************************************
** Function name:        created
** Description:             Return the creation status of the Sprite
****************************************************************************************/
bool TFT_eSprite::created(void)
{
   if (_created) return true;
   else return false; 
}

Here's an example of how I use it within a function. Here "ImageToSprite" loads a BMP file into a Sprite that was defined earlier. The pointer to the Sprite is passed:

ImageToSprite("woof.bmp", &spr01)

Within the function the existence of the Sprite is checked before proceeding with the rest of the function:

bool ImageToSprite(char *FileName, TFT_eSprite *_spr)
{
    if (!_spr->created())
    {
        Serial.print("Undefined Sprite");
        return false;
    }
}

In summary, this provides a way to place some error checking in your code.

Cheers

Bodmer added a commit that referenced this issue Jul 6, 2020
New function added:
  bool created(void);
to check if sprite has been rotated. Example:

if ( !spr.created() ) Serial.println("Sprite has not been created");
@Bodmer
Copy link
Owner

Bodmer commented Jul 6, 2020

Done, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants