Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3690610
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T04:03:17+00:00 2026-05-19T04:03:17+00:00

I have an Entity baseclass which the classes Player and Enemy Inherit. class Entity

  • 0

I have an Entity baseclass which the classes Player and Enemy Inherit.

class Entity
{
  public:

    virtual void Update(sf::RenderWindow &window) {};
    virtual void Draw(sf::RenderWindow &window) {};

};

Both player and enemy contain a sprite object that looks like this:

class Player : Entity
{
   public:

   sf::Sprite sprite

    void Update(sf::RenderWindow &window);
    void Draw(sf::RenderWindow &window)
}

Player and Enemy are created inside a vector which is set up like this:

class EntityManager
{
   public:
   void CollisionCheck();
   private:
   std::vector<Entity*> entityVector;
}

I’m looking to use a collision detection function of this form:

bool Collision::CircleTest(const sf::Sprite& Object1, const sf::Sprite& Object2)

So I’m trying to do something like this:

void EntityManager::ColCheck()
{
   if (Collision::CircleTest(entityVector[0]->sprite, entityVector[1]->sprite))
      {
         cout << "COLLISION\n";
      }
}

This results in the following compile error:

‘class Entity’ has no member named ‘sprite’

I’m unsure how to create a dummy sprite in Entity so that I can access the player and enemy sprites using the above method. Is this possible?

I’m stumped and would greatly appreciate any help anyone can offer!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T04:03:17+00:00Added an answer on May 19, 2026 at 4:03 am

    If everything in your code that derives from Entity has a sprite object, then you should declare that object in the base class.

    Not declaring the object in the base class means that there could be a class inheriting from Entity that does not have a sprite object, which means that ColCheck has no valid basis for assuming that elements of entityVector point to something that has a variable called sprite. Make sense?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an Entity baseclass which the classes Player and Enemy Inherit. Both player
I have the following classes in my Model: public abstract class Entity : IEntity
Using NHibernate.Mapping.Attributes, I have a entity class with something like: [Class] public class EntityA
I have the following entity structure: public class Party { public Int32 PartyId {
I have a whole list of entity classes which I need to make Serializable
I have quite a complex entity structure where several classes inherit from a base
I have a declarative base class Entity which defines the column name as polymorphic,
I have an entity that maps to an external oracle table which is one
I have an entity class that has a property with an underlying db column
I have the following entity class (in Groovy): import javax.persistence.Entity import javax.persistence.Id import javax.persistence.GeneratedValue

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.