-
Notifications
You must be signed in to change notification settings - Fork 496
FlxSound: Add loopCount and loopUntil #3546
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Conversation
MondayHopscotch
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Haven't run the code locally (looking at this from my phone), but the code looks good. I use my own sound middleware, so I am not experienced with FlxSound - but this seems very nice to spare folks from having to track loop counts themselves.
👍
|
As in the original PR I made, it would technically make sense to keep the sound looped instead of freely allowing the loopUtil and loopCount. This would otherwise be confusing due to the fact the variables are connected to looped, in a way, but that's just my opinion |
I don't follow, I don't quite know what "freely allow" means in this context and I don't see any significant difference in behavior between this approach and yours. if possible use a code snippet and say what the behavior is compared to what you would prefer |
He means like, make Either only have |
|
When making this I thought requiring For example the following code would not loop, but IMO the dev had the intent to loop twice: sound = new FlxSound();
sound.load("assets/sounds/my-sound.mp3");
sound.loopUntil = 2;
sound.play();I can't foresee a case where a dev might ever want to set looped to false while also setting a loop count. @MondayHopscotch I'd appreciate your thoughts as well Whichever we go with, I think a clarifying doc will help avoid most confusion |
Then ig the least confusing approach would be automatically toggling |
That's a fair point, I automatically toggle looped off when the |
|
I'm just thinking through how you'd use it. Seems like these are the intended uses: Play a sound 3 times in row (initial play + 2 loops): Play sound that loops forever: To re-play a sound, since it resets, you just call play again: Does that sound right? |
Yep, that's it |
Note that in the last example the second play() will not play 3 more loops, it will play once. If you want to play all three again you would call |
|
I don't know what side eye emoji means, can I some more concrete feedback on that? |
It isn't side eye, it just represents observing and in this context, it's about how the topic just interesting and amazing to acknowledge, so in this case, the feedback would be that the code looks very good and seems ready to already be implemented |
|
I meant it as I'll look at it... but then I didn't go look at it because I got busy/distracted. If I'm understanding correctly, the first time you play a sound that was set up to be looped, it loops. After that, It feels a little weird, but at the same time not something that is hard to manage. I feel that a perfect world is that calling |
|
Not really, since play just replays the sound, it shouldn't impact the loops at all, with true it restarts it forcibly which would make sense to then have the looped version again because it cleansup the sounds, hence the loops reset to 0 so it would make sense |
|
It feels odd to me that: Means it plays and loops twice (plays 3 times) But later on Means it plays just once. If the key here that I'm missing is that |
A fair point to bring up, my reasoning behind this is that when you call play() with a forceRestart of false while it's playing, nothing changes, so play already checks the current state. Another option, is to reset loopCount to 0 on play calls after it finished looping. This matches the existing behavior where play(false) calls on completed sounds behave the same as Curent way: // restart loops before completion
play(true);
// restart loops after completion
play(true);
// play once more after completing(assuming anyone specifically wants this)
play();The way mentioned above: // restart loops before completion
play(true);
// restart loops after completion
play(); // or play(true);
// play once more after completing loops
loopsUntil = 0;
play(true);The existing doc for play is ambiguous, here. But I notice that play(false) on a completed sound starts at 0 by default and when it's playing, they simply unpause at their current point. |
done |
Alternative to #3478
Test state:
We can't unit test sounds, for now