-
Notifications
You must be signed in to change notification settings - Fork 494
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 |
Alternative to #3478
Test state:
We can't unit test sounds, for now