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

Pages: 1 2 3 [4] 5
46
Window / Re: SFML Events in Qt creator
« on: March 24, 2014, 01:30:24 pm »
In your first post, you write:
cout << "work" << endl;

In your last post, your code contains:
cout << "work";

Last one will not print "work" unless you call std::endl sometime.

47
Graphics / Re: Zoom problem
« on: March 21, 2014, 10:17:22 am »
You will have to map your Mouse-Coordinates (which are in Pixel on your Monitor) to you World-Coordinates, to get the Mouse-Position in your world.

Something like this :
sf::View view = window.getView();
//If not in fullscreen you have to substract the window-position, since the mouse-position is the pixel on your monitor
sf::Vector2f mousepos = window.mapPixelToCoords(sf::Mouse::getPosition()-window.getPosition());
view.zoom(0.9f);
view.setCenter(mousepos);
window.setView(view);
//set the cursor to your new center
sf::Mouse::setPosition(window.mapCoordsToPixel(mousepos)+ window.getPosition());

48
If you want to learn more about Views, you should look in the Tutorials:
http://www.sfml-dev.org/tutorials/2.1/graphics-view.php

But since you use a single VertexArray and use a Translate to move the Stars, I'm not really sure if you would gain any advantage in using a View.

49
General / Re: How to Delete/Remove Sprite?
« on: February 26, 2014, 11:05:34 am »
You dont have to Remove a sprite.

What do you want to achive by doing something like that?

50
General / Re: Problems compiling a program on Ubuntu
« on: February 03, 2014, 10:23:40 am »
An easy way in Ubuntu to get alle dependencies is to just install den dependencies of the old SFML-package (1.6)

sudo apt-get build-dep libsfml-dev

This will only install the dependencies without the actual package.

51
General / Re: Set fixed sprite position when sf::View is active?
« on: January 16, 2014, 03:32:06 pm »
You have to use one view for the map and one view for the HUD.

Something like this:

window.setView(viewMap);
window.draw(map);
window.setView(viewHUD);
window.draw(sprite);

52
General / Re: Problem with setFramerateLimit()
« on: December 19, 2013, 01:02:45 pm »
I suppose this is quite inaccurate
float fps = 1.f / c.restart().asSeconds();

You should rather try:
int fps = 1000000 / c.restart().asMicroseconds();


(untested) ;-)

53
Graphics / Re: setPosition() for private sprites
« on: November 28, 2013, 11:17:08 am »
Whoops, my bad, you don't have to set the size of the sprite in that case.

But that function is still at fault.

You get get global bounds of the sprite (so the coordinates where it is drawn),
but use those bounds to set the TextureRect.

You should use getTextureRect instead of getGlobalBounds.

54
Graphics / Re: setPosition() for private sprites
« on: November 27, 2013, 03:11:56 pm »
I guess your update-function is at fault:
void Bar::update()
{
    sf::FloatRect bounds = filling.getGlobalBounds();

    filling.setTextureRect( sf::IntRect(
                                bounds.left, bounds.top, step * current, bounds.height ) );
}

You update the TextureRect, but not the size of the Sprite. (So the sprite stays the same size and the texture gets stretched=

Depending on the direction you want to reduce the filling, you will have to resize the size of the sprite too.

Thats wrong, sorry. Just use getTextureRect instead of getGlobalBounds.

55
Graphics / Re: Resolution-Independent Rendering?
« on: November 23, 2013, 04:55:44 pm »
Did you try Views?

56
Graphics / Re: Not sure if bug or not, getting division by zero...
« on: November 15, 2013, 09:58:16 am »
This looks a litte bit strange to me:

if(!tx.back().loadFromFile("png/beans.png")) cout << "could not open breeagfdso" << endl;
            icons.push_back(Sprite(tx.back()));

So even if the texture cannot be loaded, you create a sprite for it.
Should IMHO rather be something like this:

if(!tx.back().loadFromFile("png/beans.png")) cout << "could not open breeagfdso" << endl;
            else icons.push_back(Sprite(tx.back()));



Did you try to reserve Memory for your vector?
The way it is know, it might happen that your textures get reallocated 6 Times (when i = 2, 3, 5, 9, 17 and 33)

void init()
    {
        tx.reserve(50);
        for(int i = 0; i < 50; ++i)


57
Graphics / Re: Color changing 2 times
« on: November 14, 2013, 03:58:13 pm »
That Shader posted by G. draw the Sprite in a single Color, defined by:
shader.setParameter("color", sf::Color::Green);

For the outline you draw the Sprite 8 times in Black with an offset in every direction, so it will be larger than the original Sprite.

After that in green at the original location.

58
Graphics / Re: Color changing 2 times
« on: November 14, 2013, 12:20:42 pm »
I don't know if it is usefull to you, but what if you change your original texture of the sprite to grey-scale an then set the color with sprite.setColor?

59
General discussions / Re: Favorite IDE
« on: November 13, 2013, 09:54:45 am »
I started with Code::Blocks and also tried Eclipse and Netbeans.

But I'm using QtCreator now and keep it that way :-)

60
General / Re: How Can I limit what to draw
« on: October 25, 2013, 10:14:56 am »
It looks like you are drawing every tile as a single sprite.

You should take a look at VertexArrays, to speed up the drawing.

http://www.sfml-dev.org/tutorials/2.1/graphics-vertex-array.php

(Especially the part about tilemap)

Pages: 1 2 3 [4] 5