Jump to content
  • Advertisement
Sign in to follow this  

How should I do this [C++/SFML]

This topic is 2059 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have a ObjectType class and a ObjectInstance class. ObjectInstance is just an instance of the ObjectType.


I want to be able to draw ObjectInstance based on the ObjectType class, something like the following

void ObjectInstance::draw()

where type is the ObjectType that is stored inside ObjectInstance.


The simplest way is to store a sprite in ObjectType and set the position when I am drawing.

The other method that I know of is to make use of sf::VertexArray + sf::Transform().translate to draw.


I am wondering if there is any other way to do so.


I know I can just store sprite in the ObjectInstances, but just say that if I need to do this, how should I do it? 






Share this post

Link to post
Share on other sites

Maybe you should take a look at these sources and maybe even buy the book: SFML Game Development. As you can see in the sources, they let every scenenode (or object or whatever) inherit from sf::drawable and sf::transform. After that, they override the draw method in all entities to draw a sprite. This sprite is just stored inside the entity.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!