Jump to content

View more

Image of the Day

Boxes as reward for our ranking mode. ヾ(☆▽☆)
#indiedev #gamedev #gameart #screenshotsaturday https://t.co/ALF1InmM7K
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

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

4: Adsense

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.


  • You cannot reply to this topic
1 reply to this topic

#1 ZwodahS   Members   

483
Like
0Likes
Like

Posted 23 February 2014 - 02:39 AM

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()
{
    type.draw(*this);
}

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? 

 

 

 

 

 


Check out my blog at zwodahs.github.io and zwodahs.itch.io/


#2 ProtectedMode   Members   

1339
Like
1Likes
Like

Posted 24 February 2014 - 01:49 AM

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.






Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.