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 - Artifact

Pages: [1]
1
Graphics / Re: Texture not working from header c++
« on: July 30, 2014, 06:07:47 pm »
I'm sure that its loading the texture, it works fine if I cut the texture line from the header file into  the .cpp file.  I have no idea why it isn't working.

2
Graphics / Texture not working from header c++
« on: July 30, 2014, 04:43:23 pm »
Hello, I'm trying to load a texture and a sprite. This works fine as long as I define them inside my .cpp file, but if I move the texture to the header file nothing is shown in the window.

Here is the header file:

#pragma once
#include <SFML/Graphics.hpp>
using namespace sf;
class GameObject
{

public:
        GameObject();
        ~GameObject();
        void Draw(RenderWindow *);
        void Update();
        Sprite sprite;
        Texture texture;
};

This is the .cpp file:

GameObject::GameObject()
{      
       
        if (!texture.loadFromFile("sprite.png"))
        {

        }

        sprite.setTexture(texture);
       
}

void GameObject::Draw(RenderWindow * window)
{      
        window->draw(GameObject::sprite);
}

I tried debugging it at it looks like my texture doesn't have a y size when its defined inside the header. Why is that?

Note: I'm a C# programmer who is trying to play around with C++, there might be some things, that I dont understand yet.

Pages: [1]
anything