You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The title screen shows, but you can't select different options 😮! WHAT'S HAPPENING😱!?
I deleted the code that selects the next and previous options on the TitleScreen. To fix this issue you'll have to add that code back!
Where's The Problem?
File: src/screen/TitleScreen.java
Functions: getNextMenuItem( ... ) and getPreviousMenuItem( ... )
To fix this issue you will need to add code to both of the above functions.
Instructions
According to the comments above the two functions in TitleScreen.java:
getNextMenuItem( ScreenType selectedMenuItem ) is passed in the currently selected item and should return the next item to select.
getPreviousMenuItem( ScreenType selectedMenuItem ) is passed in the currently selected item and should return the previous item to select.
Let's start by working on getNextMenuItem( ... ).
getNextMenuItem( ... )
When is pressed getNextMenuItem( ... ) is called to retrieve the next menu item. When the TitleScreen starts Play is selected.
When is pressed High Scores should get selected.
When is pressed again Exit should get selected.
Finally, when is pressed again Play should get selected.
And so on...
Right now getNextMenuItem( ... ) always returns ScreenType.GameScreen as the next menu item, which is why Play is always selected. To fix this you need to return the appropriate next menu item. Use selectedMenuItem to detect the currently selected menu item, then return the correct next menu item using a member of ScreenType. To do this follow the 4 steps below:
At this point you should be able to compile and run your code, and use the key to select items on the title screen. Great Job!
Now we need to do something similar for getPreviousMenuItem( ... ) so the correct menu item is chosen when is pressed.
getPreviousMenuItem( ... )
I'l let you figure this one out on your own 😄. Hint: use the working version of Invaders to figure out what should happen when the up key is pressed, then make this behavior happen by returning the correct values from getPreviousMenuItem( ... ).
After you have fixed this bug:
Commit and push your changes to GitHub
For groups, have each group member sync, run and test the latest code to make sure everything is working properly.
Problem
The title screen shows, but you can't select different options 😮! WHAT'S HAPPENING😱!?
I deleted the code that selects the next and previous options on the
TitleScreen. To fix this issue you'll have to add that code back!Where's The Problem?
File: src/screen/TitleScreen.java
Functions:
getNextMenuItem( ... )andgetPreviousMenuItem( ... )To fix this issue you will need to add code to both of the above functions.
Instructions
According to the comments above the two functions in TitleScreen.java:
getNextMenuItem( ScreenType selectedMenuItem )is passed in the currently selected item and should return the next item to select.getPreviousMenuItem( ScreenType selectedMenuItem )is passed in the currently selected item and should return the previous item to select.Let's start by working on
getNextMenuItem( ... ).getNextMenuItem( ... )When
is pressed
getNextMenuItem( ... )is called to retrieve the next menu item. When theTitleScreenstarts Play is selected.When
is pressed High Scores should get selected.
When
is pressed again Exit should get selected.
Finally, when
is pressed again Play should get selected.
And so on...
Right now
getNextMenuItem( ... )always returnsScreenType.GameScreenas the next menu item, which is why Play is always selected. To fix this you need to return the appropriate next menu item. UseselectedMenuItemto detect the currently selected menu item, then return the correct next menu item using a member ofScreenType. To do this follow the 4 steps below:return ScreenType.GameScreen;ifselectedMenuItemequalsScreenType.GameScreenreturn
ScreenType.HighSoresScreenelse ifselectedMenuItemequalsScreenType.HighScoreScreenreturn
ScreenType.EndGameelsereturnScreenType.GameScreenDon't forget to add brackets! Your if statements should look something like this:
At this point you should be able to compile and run your code, and use the
key to select items on the title screen. Great Job!
Now we need to do something similar for
is pressed.
getPreviousMenuItem( ... )so the correct menu item is chosen whengetPreviousMenuItem( ... )I'l let you figure this one out on your own 😄. Hint: use the working version of Invaders to figure out what should happen when the up key is pressed, then make this behavior happen by returning the correct values from
getPreviousMenuItem( ... ).After you have fixed this bug: