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

Pages: [1]
1
General / Re: Thor2.0: Linking resource / texture to Animation
« on: February 26, 2015, 05:32:05 pm »
Yup it sure was,  moved out of the main loop and now it's animated.   Thanks again for your time,  really rescued my afternoon.

2
General / Re: Thor2.0: Linking resource / texture to Animation
« on: February 26, 2015, 05:01:48 pm »
I've never used Thor, but it looks like your problem is that you're mixing lowercase and capital letters.

animator.addAnimation("idle", Idle, sf::seconds(1.f));
animator.playAnimation("Idle", true);
 

"idle" vs "Idle"


good "eye"!  That was the cause of the assertion.   It surprisingly didn't enumerate through frames,  it was just a still frame.   At least now I can tinker and find out why,  thank you very much to the both of you.

3
General / Re: Thor2.0: Linking resource / texture to Animation
« on: February 26, 2015, 04:03:25 pm »
I appreciate you fixing the code tags,  I thought they looked odd.   I've also updated the code above and will keep that in mind for the future.

I'm not sure what i'm looking for.   animator.playAnimation(...) makes the call, goes through alot of pointer magic,  and ends up at the playAnimation() function definition where it throws.   If I just run it without breakpoints,  the call stack is empty on the assertion.





//////////////////////////////



4
General / Re: Thor2.0: Linking resource / texture to Animation
« on: February 26, 2015, 02:32:30 pm »
Thank you.   I've been thumbing through forums and docs while completely missing the examples folder.   Since I have your attention,  is this runtime error familar to you?   Everything should be linked correctly,  using the debug libs in debug mode etc.

Error:



Produced from the following @ animator.playAnimation();
#include <Windows.h>
#include <SFML\Graphics.hpp>
#include <Thor\Animations.hpp>
#include <Thor\Graphics.hpp>

#define frames 6

sf::IntRect rect[] = {
        { 83, 28, 40, 92 },
        { 133, 27, 41, 93 },
        { 183, 27, 41, 93 },
        { 235, 27, 38, 93 },
        { 283, 28, 38, 92 },
        { 332, 28, 39, 92 },
        { 381, 28, 40, 92 },
};


int WINAPI WinMain(HINSTANCE hInstance,
        HINSTANCE hPrevInstance,
        LPSTR lpCmdLine,
        int nCmdShow)
{



        sf::Vector2f Screen(600, 400);
        sf::RenderWindow window(sf::VideoMode(Screen.x, Screen.y), "Title");


        sf::Image img;
        img.loadFromFile("img.png");

        sf::Color color(159, 82, 159);
        img.createMaskFromColor(color);

        sf::Texture tex;
        tex.loadFromImage(img);

        sf::Sprite sprite;
        sprite.setTexture(tex);


        thor::FrameAnimation Idle;

        for (int c = 0; c <= frames; c++)
        {
                Idle.addFrame(1.f, rect[c]);
        }

        thor::Animator<sf::Sprite, std::string> animator;
        animator.addAnimation("idle", Idle, sf::seconds(1.f));


        sf::Clock frameclock;

        while (window.isOpen())
        {
                sf::Event event;
                while (window.pollEvent(event))
                {
                        switch (event.type)
                        {
                        case sf::Event::Closed:
                                window.close();
                                break;
                        }


                }

                animator.update(frameclock.restart());
                animator.playAnimation("Idle", true);

                animator.animate(sprite);

                window.draw(sprite);
                window.display();
                window.clear();

        }

}


I've seen a few posts here with other people having similar runtime errors but with different references.   One suggestion was to rebuild with Cmake,  check the examples box and test.   I've tried this as well.   It's some simple user error surely.

5
General / Thor2.0: Linking resource / texture to Animation
« on: February 26, 2015, 07:11:30 am »
Hello!

I've just got Thor 2.0 installed and found myself puzzled at how to point a sprite to it's texture.

Rough example,  previously...
sf::Image img;
img.loadfromfile("file.png");

//mask it

sf::Texture tex;
tex.loadfromimage(img);

sf::Sprite sprite;
sprite.setTexture(tex);

sf::intRect *rect;
sprite.setTextureRect(rect); //loop or do whatever  rect[i]
 


i'm not sure how to make sure those animations are over the correct texture.   If you had something like...
#define frames 2

sf::IntRect rect[] = {
{0,0,0,0},
{1,1,1,1},
{2,2,2,2}
};
        thor::ResourceKey<sf::Texture> key = thor::Resources::fromFile<sf::Texture>("image.jpg");

        thor::ResourceCache<sf::Texture> cache;  
        cache.acquire(key);

        std::shared_ptr<sf::Texture> texture = cache.acquire(key);  

        thor::FrameAnimation Idle;

        for (int c = 0; c <= frames; c++)
        {
                Idle.addFrame(1.f, rect[c]);
        }

        thor::Animator<sf::Sprite, std::string> animator;
        animator.addAnimation("Idle", Idle, sf::seconds(1.f));

.........

       animator.play(Idle);
 



So even though the documentation is really helpful,  my understanding of linking the resources to the sprites or FrameAnimations is fuzzy.   In theory,  the intRect's and texture are there,  now how do you tell the program which resource to use it's intRect's over?     


VS2013 Express
Windows 7 64bit OS
Latest version of SFML and Thor

Pages: [1]
anything