Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - kyle_michiels

Pages: [1]
1
Thanks for the quick reply!

I noticed there was an initialization error which fixed itself in debug mode but I had to initialize it for release mode.

And with the non "-d" files it works perfectly!

Many thanks!

2
Hey Guys,

I finally finished my project and it runs without error in Debug Mode,
However, when I switch to Release Mode it complains that it can't find my resources.
I included the assets folder with the EXE but it still can't find the files.

The error:


The file structure:



The structure is similar to the debug folder and just works fine in Debug mode.
I tried removing the "-d" from the lib files but this didn't make any difference.

I hope someone can help me out.

Greetings,

Kyle

3
Graphics / Drawing a sprite from within a list, within a list
« on: November 07, 2017, 07:11:43 pm »
Hey guys!
Im trying to draw a sprite within a list of components, within a list of gameobjects.
These are custom classes I have written.

How I'm trying to draw the sprite:
for (std::list<GameObject*>::iterator it = gameObjects.begin(); it != gameObjects.end(); it++)
   {
      std::list<Component*>  compList = it._Ptr->_Myval->GetAllComponents();
      for (std::list<Component*>::iterator ita = compList.begin(); ita != compList.end(); ita++)
      {
         Graphic *g = static_cast<Graphic*>(ita._Ptr->_Myval);
         if (g)
         {
            
            sf::Sprite sprite = g->GetDrawable();

            if (g->GetDrawable().getTexture() == nullptr)
            {
               std::cout << "No texture has been assigned" << std::endl;
            }

            _window.draw(sprite);
         }
         else
         {
            std::cout << "Casting Failed" << std::endl;
         }

      }


GameObject Logics (simplefied):

std::list<Component*> components;
void ECE::GameObject::AddComponent(Component & c)
{
   components.emplace_back(&c);
}
std::list<Component*> ECE::GameObject::GetAllComponents()
{
   return components;
}


And the Graphic class logics:

sf::Sprite _sprite;
sf::Sprite ECE::Graphic::GetDrawable()
{
   return _sprite;
}


And finally adding the Graphic to the gameobject:

ECE::Graphic _G_myGraphic;
TestObject::TestObject()
{
   _G_myGraphic.SetTexture("Game/GFX/mario.png");
   _G_myGraphic.SetPostion(sf::Vector2f(100, 100));
   AddComponent(_G_myGraphic);
}



And lastly adding the gameObject to the gameObject list:

void TestGame::Start()
{
   AddGameObject(_GO_testObject);
   std::cout << "Added gameObject" << std::endl;
}

void ECE::Game::AddGameObject(GameObject & go)
{
   gameObjects.emplace_back(&go);
}


I can print any data from the sprite, but just drawing it seems to be a problem.
Any help would be appreciated!

Greetings!

Kyle

Pages: [1]