Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: SIGSEGV fault while using thor::FrameAnimation  (Read 3860 times)

0 Members and 1 Guest are viewing this topic.

N1ghtly

  • Jr. Member
  • **
  • Posts: 96
    • View Profile
SIGSEGV fault while using thor::FrameAnimation
« on: August 30, 2011, 11:10:16 pm »
So I was checking out this awesome lib called Thor :)
This is my code snippet:
Code: [Select]
for(int i = 0; i < 701; i+=100)
        for(int j = 0; j < 701; j+= 100)
        {
            sf::IntRect temp(sf::Vector2i(i, j), sf::Vector2i(100, 100));
            ani->AddFrame(1, temp);
        }
    ani->Apply(spr, 50);

ani is a FrameAnimation ptr.

I really don't understand how that could happen...
The SIGSEGV points to a fault with a vector (probs the one that FrameAnimation class uses?)

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
SIGSEGV fault while using thor::FrameAnimation
« Reply #1 on: August 31, 2011, 12:24:46 am »
Maybe you dereference an uninitialized smart pointer. Did you initialize ani?
Code: [Select]
thor::FrameAnimation::Ptr ani( new thor::FrameAnimation() );
Otherwise, do you have a minimal complete example with this error? I don't see a mistake in your code.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

N1ghtly

  • Jr. Member
  • **
  • Posts: 96
    • View Profile
SIGSEGV fault while using thor::FrameAnimation
« Reply #2 on: August 31, 2011, 12:47:13 am »
omg ofcourse! thanks nexus, and great lib!

Haikarainen

  • Guest
SIGSEGV fault while using thor::FrameAnimation
« Reply #3 on: August 31, 2011, 08:46:18 am »
shouldnt these kinda questions be asked in projects>thor and not sfml>graphics ? ;p this forum could need some mods to maintain structure here!

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
SIGSEGV fault while using thor::FrameAnimation
« Reply #4 on: August 31, 2011, 12:08:36 pm »
Quote from: "Haikarainen"
shouldnt these kinda questions be asked in projects>thor and not sfml>graphics ?
As stated in the other thread, that's probably not a good idea. I'd like to keep the Thor thread for design discussions and announcements.

Don't forget you can still contact me via e-mail :)
But during the next two weeks, I won't have much occasion to answer questions... So read the docs carefully, ask other users or wait :P
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

N1ghtly

  • Jr. Member
  • **
  • Posts: 96
    • View Profile
SIGSEGV fault while using thor::FrameAnimation
« Reply #5 on: August 31, 2011, 03:27:45 pm »
I succesfully tested FrameAnimation to make an explosion, but when I use it in my game, it gives me a runtime error.
Code: [Select]
Assertion failed: itr != mAnimationMap.end()
in animator class


??

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
SIGSEGV fault while using thor::FrameAnimation
« Reply #6 on: August 31, 2011, 06:40:38 pm »
You cannot play an animation that is not stored in the Animator.

Generally, a failed assertion indicates almost always a violated precondition. Here it is has not been explicitly mentioned in the documentation (until now). If something goes wrong, you should look at the docs for the corresponding function, there you are likely going to find the mistake.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

N1ghtly

  • Jr. Member
  • **
  • Posts: 96
    • View Profile
SIGSEGV fault while using thor::FrameAnimation
« Reply #7 on: August 31, 2011, 10:14:07 pm »
It is stored...
Here's how I init:
Code: [Select]
void GameState::initAni()
{
    explosionSprite.SetTexture(im.getImage("explosion18.png"));
for(unsigned i = 0; i < 2050; i+=128)
        for(unsigned j = 0; j < 2050; j+= 128)
        {
            sf::IntRect temp(j, i, 128, 128);
            ani->AddFrame(1.f, temp);
        }
    ani->Apply(explosionSprite, 1.f);
    animator.AddAnimation("explosion", ani, 2);
}


Then I call:
Code: [Select]
void GameState::playExplosion(float x, float y)
{
    explosionSprite.SetPosition(x+50, y+50);
    animator.PlayAnimation("explosion");
    explosionCount++;
}
[/quote]

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
SIGSEGV fault while using thor::FrameAnimation
« Reply #8 on: August 31, 2011, 10:36:49 pm »
I don't think it is added, otherwise it would be found. Is initAni() called? Please provide a minimal complete example that reproduces the problem, or try to reduce the code until the mistake becomes obvious, or use the debugger to check the Animator's std::map. But remember that I won't have a lot of time from tomorrow... ;)
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

N1ghtly

  • Jr. Member
  • **
  • Posts: 96
    • View Profile
SIGSEGV fault while using thor::FrameAnimation
« Reply #9 on: September 01, 2011, 09:18:57 am »
OMG!
I feel so stupid, 2 noob mistakes in 2 days :(
thanks, it works great now!

EDIT: How do I know when the animation finishes? Should I set my own sf::Clock for that? Because after it finishes I don't need to draw it anymore.

Haikarainen

  • Guest
SIGSEGV fault while using thor::FrameAnimation
« Reply #10 on: September 01, 2011, 09:50:44 am »
Quote from: "Nexus"
As stated in the other thread, that's probably not a good idea. I'd like to keep the Thor thread for design discussions and announcements.

Don't forget you can still contact me via e-mail :)
But during the next two weeks, I won't have much occasion to answer questions... So read the docs carefully, ask other users or wait :P


You should create a small forum on bromeon.ch for thor, and link to it on your thor-thread here! :)

 

anything