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

Pages: [1]
1
Graphics / Sprites appear white (Yes, I do know what that means)
« on: July 03, 2011, 01:28:10 am »
Yes but, the way I coded it, the images/sprites don't copy themselves, do they ? I mean, I place the Image class in a vector, THEN I tell it, from the vector, to load the image and set the sprite. The way I see it, nothing is copied, but it's maybe just me.

2
Graphics / Sprites appear white (Yes, I do know what that means)
« on: July 03, 2011, 01:00:36 am »
Okay, so I'm currently making a game with paperdoll (So you see the armor and hats of the other players, depending of what they have equipped), so I thought of having all the armors with their id on different files (So the armor id0 would be 0.png, etc...) and have created a class to handle those, but weirdly, only the last armor in the vector shows, the other shows as white squares.

(The code that loads the different armor into an "Image" vector)
Code: [Select]
for (int i=0; i<m_numBody; i++)
{
    Image img;
    m_body.push_back(img);
    m_body[i].Init("body", i);
}


(The code that calls the drawing function of the "Image" class, 'body' being the armor id)
Code: [Select]
m_body[body].Draw(App, pixelX, pixelY, direction, anim);

And then there is the Image class :

(image.h)
Code: [Select]
#ifndef IMAGE_H_INCLUDED
#define IMAGE_H_INCLUDED

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

class Image
{
    public:
void Init(std::string type, int number);
void Draw(sf::RenderWindow &App, int pixelX, int pixelY, int direction, int anim);

    private:
sf::Image m_image;
sf::Sprite m_sprite;
};

#endif // IMAGE_H_INCLUDED


(image.cpp)
Code: [Select]
#include <string>
#include <sstream>
#include <iostream>
#include "image.h"

using namespace std;

void Image::Init(string type, int number)
{
// Load the sprite
ostringstream t_stream;
    t_stream << "data/sprites/" << type << "/" << number << ".png";
    string t_string = t_stream.str();

m_image.LoadFromFile(t_string.c_str());
m_image.SetSmooth(false);
m_image.CreateMaskFromColor(sf::Color(255, 0, 255));
m_sprite.SetImage(m_image);
}

void Image::Draw(sf::RenderWindow &App, int pixelX, int pixelY, int direction, int anim)
{
// Draw the sprite
m_sprite.SetSubRect(sf::IntRect(32*direction-32, 48*anim, 32*direction, 48*anim+48));
m_sprite.SetPosition(pixelX, pixelY);

App.Draw(m_sprite);
}


Like I said, only the last armor (I tested with different numbers) shows. So if there is 4 armors, only m_body[3].Draw(...) would work, the others, like m_body[1].Draw(...) would show a white square)

Thank you.

3
Graphics / Problem with sf::Font
« on: February 13, 2011, 07:13:12 am »
Hello,

I'm having a problem when I take an sf::Font and set it at low size.
The font is all smoothed out in an ugly way. (Which is btw, a pixel-art font)
I tried different fonts, same problem.
Is there a sf::Font.SetSmooth function ? Because I can't seem to find one on the doc.

Thank you.

Pages: [1]