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

Pages: [1]
1
Read the official tutorial on sprites and textures.  You're experiencing the "white square problem".

Ah. Okay. Thanks a lot again, didn't get to the end of the tutorial :(

2
Damn. Well, now it works, but as I compile the program and start it, I can only see white rectangle on the gamescreen. And if I'm loading the same texture and assigning it to the sprite from Game.cpp and load this one it works.
So why doesn't the Player's sprite work properly?

3
By the way, if you want an explanation for the first error you were getting, look up the "Most Vexing Parse".

Thanks! I'll do that!

4
Oh, well. Seems like I forgot to set inheritance from sf::Drawable as public. So that's the issue.

5
Try and remove the () from this line: Player player();
Hm, now it's error C2243: 'type cast' : conversion from 'Player *' to 'const sf::Drawable &' exists, but is inaccessible

6
Hello there!

I'm trying to draw an entity using inheritance from sf::Drawable like in "Designing your own entities with vertex arrays" tutorial (http://www.sfml-dev.org/tutorials/2.1/graphics-vertex-array.php).

But as the screen loads I can only see a white rectangle of my sprite, not the actual sprite.
If I load the same texture and assign it to the sprite from Game.cpp the sprite loads properly.

So why isn't the sprite from Player class working properly?

The entity I'm trying to draw:
#include "Player.h"

#include <SFML/Graphics.hpp>
#include <ostream>

const int STARTING_HEALTH = 100;

Player::Player()
{
        x=y=20;
        dx=dy=1;
        health = STARTING_HEALTH;
        sf::Texture texture;
        texture.loadFromFile("resources/player.jpeg", sf::IntRect(30, 145, 82, 125));
        m_sprite.setTexture(texture);
}

void Player::draw(sf::RenderTarget& target, sf::RenderStates states) const
{
        target.draw(m_sprite);
}

It's header:
Entity is inherited from sf::Drawable

#ifndef PLAYER_H
#define PLAYER_H

#include <SFML/Graphics.hpp>
#include "Entity.h"

class Player : public Entity
{
public:
        Player();
        virtual void draw(sf::RenderTarget& target, sf::RenderStates states) const;
};

#endif // PLAYER_H
 

And the main game entry:
Game.cpp
#include <SFML/Graphics.hpp>
#include "Player.h"

int main()
{
    sf::RenderWindow window(sf::VideoMode(1000, 800), "Game Window");
       
        Player player;

    while (window.isOpen())
    {
        sf::Event event;
        while (window.pollEvent(event))
        {
            if (event.type == sf::Event::Closed)
                window.close();
        }
        window.clear();
                window.draw(player);
        window.display();
    }

    return 0;
}

7
General / Re: Error while trying to setup SFMLin Code::Blocks
« on: May 02, 2014, 05:52:49 pm »
Well, that was really noobish of me, so sorry for the question.
And thanks a lot for your answers! It helped me!
So now I'm happy.
Really appreciate your answers!

8
General / Error while trying to setup SFMLin Code::Blocks
« on: May 01, 2014, 10:02:53 pm »
Hi there! I'm trying to setup SFML in code blocks using the tutorial file, but I'm getting an error all the time as I launch the project. The console opens and then I get the following error:
"Entry point not found
The procedure entry point __gxx_personality_v0 could not be located in dynamic link library C:\path\sfml-graphics-d-2.dll"
What's wrong? The dll is in the C:\path-to-project\debug folder and I've done everything that was said in the tutorial :((

Pages: [1]
anything