SFML community forums
Help => Graphics => Topic started by: N1ghtly on August 30, 2011, 11:10:16 pm
-
So I was checking out this awesome lib called Thor :)
This is my code snippet:
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?)
-
Maybe you dereference an uninitialized smart pointer. Did you initialize ani?
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.
-
omg ofcourse! thanks nexus, and great lib!
-
shouldnt these kinda questions be asked in projects>thor and not sfml>graphics ? ;p this forum could need some mods to maintain structure here!
-
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
-
I succesfully tested FrameAnimation to make an explosion, but when I use it in my game, it gives me a runtime error.
Assertion failed: itr != mAnimationMap.end()
in animator class
??
-
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.
-
It is stored...
Here's how I init:
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:
void GameState::playExplosion(float x, float y)
{
explosionSprite.SetPosition(x+50, y+50);
animator.PlayAnimation("explosion");
explosionCount++;
}
[/quote]
-
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... ;)
-
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.
-
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! :)