Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / Problem displaying image, something wrong with custom classes

Author
Message
minas1
15
Years of Service
User Offline
Joined: 30th Nov 2008
Location:
Posted: 5th Dec 2008 18:06
Hi. I created a class named ObjectFactory which I will use to create objects. I also created a class Block which will create rectangles. (Yeah I know there is a default rect in darkgdk but I use my custom one for testing). So, block inherits ObjectFactory, however the image isn't displayed.

ObjectFactory.h and .cpp

Block.h and .cpp

and main:



I only get a black screen..
Bachmann
15
Years of Service
User Offline
Joined: 5th Dec 2008
Location:
Posted: 5th Dec 2008 22:48
Hey,

I think there's probably a problem with your SpriteID & ImageID being declared again in the child class. It doesn't seem to make sense to me anyway. Why do you need it twice?

Here's what I would do:

- Make your SpriteID & ImageID protected in the base class (this way you can access them from within the child class).
- Get rid of the increasId() calls and instead create a default constructor in your base class that does that automatically. You don't even have to call the base class constructor. Every time you initialise a child class the base class constructor will be called and your id will automatically increase by one.

Hope this helps!

Bachmann

Login to post a reply

Server time is: 2024-09-30 11:22:06
Your offset time is: 2024-09-30 11:22:06