arduarn:
Try this:const unsigned char *pTileTexture;
Tile(const unsigned char *pTexture) : pTileTexture(pTexture) {
}
void Draw(int posX, int posY) {
sprite.Draw(posX, posY, pTileTexture);
}
This worked! Thank you! I didn't understand the modification to the Tile constructor at first, as I thought the colon was used to pass parameters to an inherited class, but I now understand that this is the only way to modify the value of a const variable. Is that right? Is it necessary for the unsigned char to be const though? I tested without it being const and putting pTileTexture = pTexture in the body of the constructor and it still works. Is it just a case of being best practice to keep types consistent?
The other thing I'm slightly unsure of is the dereferencing. Why do I not need the dereferencing operator (*) when calling the sprite.Draw function? Is it because the pTileTexture pointer is pointing at an array?
Thanks so much for helping me with this.