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

Pages: [1] 2
1
SFML projects / Re: Glassomium - Multi-touch window manager
« on: August 30, 2012, 10:31:21 am »
Wow, this is such an amazing project and the most amazing thing is that a) There is code and binaries for Linux and b) It's open source!  It also has amazing compatibility!

2
General / Re: Slow execution on first start.
« on: August 25, 2012, 05:58:42 pm »
Does it also happen with apps not using graphics? Like when only using the system module?

3
SFML projects / Re: TGUI: a c++ GUI for SFML (with Form Builder)
« on: August 24, 2012, 04:19:57 pm »
So...Are you planning on releasing any themes? I am working on a OSX theme right now...

4
SFML projects / Re: TGUI: a c++ GUI for SFML (with Form Builder)
« on: August 23, 2012, 03:17:42 pm »
Yeah, that is exactly what I was thinking. I am implementing it just now...

5
Graphics / Re: SFML 2 views
« on: August 23, 2012, 03:06:37 pm »
Thanks for the tutorial eXpl0it3r, it's really helpful - especially the part about view ports.

6
SFML projects / Re: TGUI: a c++ GUI for SFML (with Form Builder)
« on: August 23, 2012, 03:01:02 pm »
What I have done is divided the SpriteSheet in to columns, then used a scrollbar to shift through the objects. Basically, here is my code (which I just put together very quickly):

#include <iostream>
#include <TGUI/TGUI.hpp>

using namespace std;

int main()
{
    tgui::Window window(sf::VideoMode(800, 600, 32), "Mapped Out");

    window.globalFont.loadFromFile("data/DejaVuSans.ttf");

    tgui::SpriteSheet *tileSheet = window.add<tgui::SpriteSheet>();
    tileSheet->load("data/TileSet.png");
    tileSheet->setPosition(0, 0);
    tileSheet->setCells(1, 2);

    tgui::Scrollbar* scroll = window.add<tgui::Scrollbar>();
    scroll->load("objects/Scrollbar/BabyBlue");
    scroll->setLowValue(1);
    scroll->setMaximum(2);
    scroll->verticalScroll = false;
    scroll->setPosition(0, 50);
    scroll->callbackID = 1;

    while (window.isOpen())
    {
        sf::Event event;
        while (window.pollEvent(event))
        {
            if (event.type == sf::Event::Closed)
                window.close();

            window.handleEvent(event);
        }

        tgui::Callback callback;
        while (window.getCallback(callback))
        {
            if(callback.callbackID == 1)
            {
                if(callback.trigger == tgui::Callback::valueChanged)
                {
                    int scrollValue = scroll->getValue();
                    tileSheet->setVisibleCell(1, scrollValue + 1);
                }

            }

        }

        window.clear(sf::Color(100, 175, 255));
        window.drawGUI();
        window.display();
    }
    return 0;
}
 

My current tile sheet only has 2 tiles in it, but later on - when it gets bigger - I can divide in to 3 or more and go through them (so it will be like a "slide" on a Powerpoint presentation).

I will also have a look at using views, I think that might give me a smoother animation of scrolling.

7
SFML projects / Re: TGUI: a c++ GUI for SFML (with Form Builder)
« on: August 23, 2012, 02:18:51 pm »
OK, so I have just gone through the TGUI documentation and I don't know if there is anyway to do the following.

Basically, there is an image. I do not want all of the image to be displayed at the same time, but instead allow the user to scroll through the image using scroll bars. Is this possible in TGUI? If not, then is there anyway to do this, like using views?

EDIT: I think I need to use a sprite sheet and merge it with a scroll bar...

Double Edit: I think I have figured it out! TGUI is sooo easy to use...:D

8
SFML projects / Re: TGUI: a c++ GUI for SFML (with Form Builder)
« on: August 23, 2012, 01:36:45 pm »
Thanks for the info, I think I will use TGUI as I am making a quick map editor which doesn't really need many widgets.

9
SFML projects / Re: TGUI: a c++ GUI for SFML (with Form Builder)
« on: August 22, 2012, 04:57:56 pm »
I am sorry if this question has been asked before, but what features does this library have that make it different from sfgui? Which library should I use?

10
General / Re: box2d
« on: August 22, 2012, 11:18:29 am »
You have to define the metre your self : there is no definition which I am aware of...

For example, if you have a sprite of a ten year old which is 64x64 pixels, then you can say that 1 metre is 50 pixels. This will mean that your sprite is 1.28m tall.
To implement this, you have to scale your box2d measurements up by 50 and your sfml measurements down by 50. Alternatively, you could set up a view, like this:

sf::View gameView ( sf::FloatRect (0, 0, 800 / 50, 600 / 50) );
 

Hope that helped.

11
General / Re: Physics/Colission
« on: August 22, 2012, 09:40:35 am »
Converting can get tricky sometimes. I mean, I tried to convert one sfml based file into 2.0 and even after it compiled the program didn't respond properly.

But at a first glance, alot of those errors seem to be because of thr new casing system.
e.g

Code: [Select]
sf::Sprite::GetSize -> sf::Sprite::getSize
//1.6                             2.0

12
General / Re: box2d
« on: August 22, 2012, 09:25:57 am »
Sorry about that. I automatically presumed you flipped the y axis in sfml so dont listen to me about that. (That was probably because I am addicted to realistic physics... :-X)

13
General / Re: box2d
« on: August 21, 2012, 09:28:48 pm »
Good point, setOrigin is the SFML1.6 equivalent of SetCenter...

Note to self: Must read documentation before posting answers  :-\

Edit: No wait, there is a reason it was renamed. SetOrigin does not set the centre of the sprite - it is just the point around which all transformations will happen. So after calling setOrigin and passing the position of the body to it, you will still need to call setPosition - or otherwise the sprite's top left corner will be located at the centre of the body.

14
General / Re: box2d
« on: August 21, 2012, 03:20:49 pm »
Your body won't fly down because gravity is:

b2Vec2 gravity(0.0, 9.8);
 

It should be:

b2Vec2 gravity(0.0f, -9.80f); //The minus is important. In physics, a negative force means down.
 

And bodySize is the size of the body. If the shape of the body is not a rectangle (i.e. the shape is a custom polygon), then body size should be the size of the sprite. So, for clarity, it really should be this:

exampleSprite.setPosition(bodyPos.x - spriteSize.x, - (bodyPos.y + spriteSize.y) );
 

15
General / Re: box2d
« on: August 21, 2012, 11:42:26 am »
You cannot set centre of a sprite, as there is no such function. You can implement your own function, or use the existing function - which is sf::Sprite::SetPosition - to align the centre of the sprite to the body's centre of mass. You can do it like this:

Code: [Select]
b2Vec2 bodyPos = body->GetPosition();
exampleSprite.setPosition(bodyPos.x - bodySize.x, bodyPos.y - bodySize.y);

Note that you might need to mess around with the second parameter of the setPosition function if gravity is negative in your world (i.e. b2Vec2 gravity(0.0f, -9.81f)). This works for me:

Code: [Select]
exampleSprite.setPosition(bodyPos.x - bodySize.x, - (bodyPos.y + bodySize.y) );

There are other ways of doing this, but I think that is the easiest.

Also note that you will have to declare bodySize yourself, either as a b2Vec2 or a sf::Vector2f. I don't recall there being anyway of getting the dimensions of a fixture or body, I think you will have to set it manually.

Pages: [1] 2
anything