Hi,
I'm currently re-writing my Pong clone to make a version that's actually worth its salt.
Thing is, there's a really bizarre problem I'm getting, and it's irritating too.
I've got a Sprite wrapper class set up, and I just put in a function for transparency of certain colours of pixel - it's parameterised, you just use the object and pass in the RGB values to make them transparent.
But, I'm getting an error saying that the class doesn't have the function as a member. pBall is an instance of the SpriteManager class, within spritewrapper.h. Here's the lines in main.cpp:
#include "spritewrapper.h"
pBall.LoadSprite("data/ball.bmp",GameWindow.MainWindow); // This works fine
pBall.SetTrans(0,0,0); // Won't compile - highlighted by IDE and says that
//the class SpriteManager (in spritewrapper.h) - doesn't have SetTrans as a member. It does, as you can see below.
Here's the appropriate part of spritewrapper.h:
void LoadSprite(char *pFileName,SDL_Surface *surface); // No problem
void SetTrans(int r,int g,int b); // No error flagged here
And here's spritewrapper.cpp - contains the actual implementations:
void SpriteManager::LoadSprite(char *pFileName,SDL_Surface *surface)
{
//Lots of code - no problem, works fine: compiles and works fine at runtime
}
void SpriteManager::SetTrans(int r,int g,int b)
{
SDL_SetColorKey(sprite,SDL_SRCCOLORKEY,SDL_MapRGB(sprite->format,r,g,b));
//No compiler errors here
}
What am I missing that's crashingly obvious? It all looks fine to me, everything is included where it should be, and this niggling problem in the first source box is the only one I have. Everything else compiles perfectly.
Can anybody help? It's driving me nuts, there seems no reason for this error to occur. It only seems to occur in main.cpp - and if I comment it out it compiles perfectly (but no transparency when it runs - only because the code to do it won't compile!)
Thanks in advance,
ukdeveloper.