Bug 582 - The music controller keeps switching between on and off
Summary: The music controller keeps switching between on and off
Status: RESOLVED FIXED
Alias: None
Product: CS3343_Kunkun_Loves_English
Classification: Unclassified
Component: Game Object (show other bugs)
Version: 1.0
Hardware: PC Mac OS
: --- major
Assignee: konolmyda
URL:
Depends on:
Blocks:
 
Reported: 2021-11-19 23:35 HKT by ruixinli7-c
Modified: 2021-11-19 23:50 HKT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description ruixinli7-c 2021-11-19 23:35:47 HKT
Summary:

When I clicked the mute button at the main page, the music is successfully muted. Nevertheless, when I then clicked the game button, say "IELTS" button and then redirect to the playing scene, The music is continuously changed between on and off and the button is continuously changed between muted and unmuted.

Steps to reproduce:

1. entering the game and in the login scene, click the mute button.
2. Click the "IELTS" button to redirect to the playing scene.
3. In the playing scene, you will find the problem described above.

Expected result:

It is expected after clicking the mute button and before clicking unmute, the figure of the button will not change and the music should not play.

Actual result:

After clicking the mute button and before clicking unmute, the figure of the button continuously changed between on and off and the button is continuously changed between muted and unmuted.

Suspected bug:

Sorry, I am not familiar with how you code this part.
Comment 1 konolmyda 2021-11-19 23:50:56 HKT
(In reply to ruixinli7-c from comment #0)
> Summary:
> 
> When I clicked the mute button at the main page, the music is successfully
> muted. Nevertheless, when I then clicked the game button, say "IELTS" button
> and then redirect to the playing scene, The music is continuously changed
> between on and off and the button is continuously changed between muted and
> unmuted.
> 
> Steps to reproduce:
> 
> 1. entering the game and in the login scene, click the mute button.
> 2. Click the "IELTS" button to redirect to the playing scene.
> 3. In the playing scene, you will find the problem described above.
> 
> Expected result:
> 
> It is expected after clicking the mute button and before clicking unmute,
> the figure of the button will not change and the music should not play.
> 
> Actual result:
> 
> After clicking the mute button and before clicking unmute, the figure of the
> button continuously changed between on and off and the button is
> continuously changed between muted and unmuted.
> 
> Suspected bug:
> 
> Sorry, I am not familiar with how you code this part.

Hi, Ruixin! Thanks for the reporting. Actually it is a very serious bug which significantly decrease the user experience. The problem is explained below:

In the music controller class, there is following code:

        @Override
	public void update() {

	for(int i=0; i<GlobalConstants.NUM_GAME_MODE; i++) {
		startButtons[i].handleEvent(mouse.mousePos);
		startButtons[i].update();
	}
	handleEvent(mouse);
        timeElapsed += timer.DeltaTime();
	if(timeElapsed >= 300) {
			sequenceIndex++;
			sequenceIndex %= 98;
			timeElapsed -= 300;
		}
		MusicController.getInstance().handleClickEvent(mouse.mousePos);
		mouse.isClicked = false;
	}

Nevertheless, you set mouse.isClicked = false at the end. This will cause trouble when you finish update the music controller. As in the same scene, there are other  class.

I fix this bug by doing the following with some code refactoring:

create:
        private void handleMouseClick(Mouse mouse) {
	    if(mouse.isClicked) {
			 
                MusicController.getInstance().handleClickEvent(mouse.mousePos);

		for(int i=0; i<GlobalConstants.NUM_GAME_MODE; i++) {
			startButtons[i].handleEvent(mouse.mousePos);
			startButtons[i].update();
		}
		mouse.isClicked = false;
	    }
        }
and substitute mouse.clicked by this.