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

Author Topic: [Thor] - Is there a way to tell witch animation is currently playing?  (Read 4333 times)

0 Members and 1 Guest are viewing this topic.

aNewHobby

  • Jr. Member
  • **
  • Posts: 85
    • View Profile
    • Live 4 Ever Or Die Trying
Is there a way to tell witch animation is currently playing? I know there is a way to tell if an animation is playing, but is there a way to return the string key of the currently playing animation? Or something like that...

so you could do something like...

if (anim.whatsplaying() == "anim1")
{
// Do something that is unique to when this animation is playing.
}
Twitter: @Jyinkies
My Own Little Spot on the Net: - Live4everOrDieTrying.info (Blog)

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10815
    • View Profile
    • development blog
    • Email
Re: [Thor] - Is there a way to tell witch animation is currently playing?
« Reply #1 on: August 07, 2012, 02:40:14 pm »
No there isn't you can see that easily from the documentation. :)

I guess it could be a nice feature, although it's also quite easy to design around it. ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6286
  • Thor Developer
    • View Profile
    • Bromeon
Re: [Thor] - Is there a way to tell witch animation is currently playing?
« Reply #2 on: August 07, 2012, 04:33:20 pm »
Indeed I have already thought about this. The reason why I haven't implemented a function as proposed by aNewHobby is: What do I return if no animation is playing?

I am aware that I can easily provide an alternative approach, but before I would like to know more about your use case. Why do you need to get the ID for the currently playing animation?
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

aNewHobby

  • Jr. Member
  • **
  • Posts: 85
    • View Profile
    • Live 4 Ever Or Die Trying
Re: [Thor] - Is there a way to tell witch animation is currently playing?
« Reply #3 on: August 08, 2012, 01:15:41 am »
Why do you need to get the ID for the currently playing animation?

There could be a number of reasons... like....

If (_anim.whatisplaying() == "RunAway")
{
    if (soundSIRIN.getStatus() == sf::Sound::Stopped)
               soundSIRN.play();

}

Just simple example were you can sync animations to sounds... it would need more clean up but you get the idea... also you could key things off animations themselves...


Indeed I have already thought about this. The reason why I haven't implemented a function as proposed by aNewHobby is: What do I return if no animation is playing?

Well I guess the best idea would be to return "NULL" I suppose or something like that. Strings can be a string and completely empty as well (can't they?). I'm new to programming so I may be mistaken on that.
Twitter: @Jyinkies
My Own Little Spot on the Net: - Live4everOrDieTrying.info (Blog)

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10815
    • View Profile
    • development blog
    • Email
Re: [Thor] - Is there a way to tell witch animation is currently playing?
« Reply #4 on: August 08, 2012, 01:43:42 am »
Just simple example were you can sync animations to sounds... it would need more clean up but you get the idea... also you could key things off animations themselves...
Wouldn't it make more sense to change the sound when you change the animation? I mean some "event" triggers the state of the entity and you change the animation and the sound, rather than chaning the animation and then try to figure out if the animation has changed.

Well I guess the best idea would be to return "NULL" I suppose or something like that. Strings can be a string and completely empty as well (can't they?). I'm new to programming so I may be mistaken on that.
You can only return NULL for pointers (and with C++11 it's adviced to use nullptr instead of NULL) and since he's using a template that can have any sort of type (could even be a class) you can't define any sort of default value and it would completly defeate the purpose of using templates if you'd try to define a default value for every possible ID. ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

aNewHobby

  • Jr. Member
  • **
  • Posts: 85
    • View Profile
    • Live 4 Ever Or Die Trying
Re: [Thor] - Is there a way to tell witch animation is currently playing?
« Reply #5 on: August 08, 2012, 05:16:13 am »
Just simple example were you can sync animations to sounds... it would need more clean up but you get the idea... also you could key things off animations themselves...
Wouldn't it make more sense to change the sound when you change the animation? I mean some "event" triggers the state of the entity and you change the animation and the sound, rather than chaning the animation and then try to figure out if the animation has changed.

My example was supposed to illustrate a time were you have an animation that is not synced to a sound. So if you just play a sound it will end before the animation, and if you play the sound on loop it will go past the animation end.. the above code will play the smaller sound for as long as the animation lasts allowing you to tweak the animation at will for polish with out having to go and sync and redo all your sounds.

Again, this was just an example of the top of my head.

The point being that any feature added creates its own uses. People would find uses for it I am sure that makes more logical sense. It seams like a cool thing ot be able to check if there was ana option for it.. and once the option is there you could use it in creative ways as yet not foreseen.
Twitter: @Jyinkies
My Own Little Spot on the Net: - Live4everOrDieTrying.info (Blog)

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6286
  • Thor Developer
    • View Profile
    • Bromeon
Re: [Thor] - Is there a way to tell witch animation is currently playing?
« Reply #6 on: August 08, 2012, 03:15:13 pm »
The point being that any feature added creates its own uses. People would find uses for it I am sure that makes more logical sense. It seams like a cool thing ot be able to check if there was ana option for it.. and once the option is there you could use it in creative ways as yet not foreseen.
I don't really like the philosophy "add a feature, one day it might become useful". I prefer to add features after I know they are useful ;)

And I agree with eXpl0it3r, I think there are better options than polling the animation when one wants to play synchronous sounds -- which doesn't mean such a getter would be fundamentally inappropriate. However for sound effects, I rather plan to develop in this direction:
Quote from: Nexus
If I add such functionality, I will probably implement a separate sound "animation" that can be played parallel to a graphical one.
« Last Edit: August 08, 2012, 03:17:20 pm by Nexus »
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

 

anything