public class Game
extends Fragment
reader
passed to the class in its constructor. The answers are then randomized. To
begin the game screen, the user must press the go button. When pressed the
running man moves to the 1st question. As the man arrives at the question
location, the question and answers become visible. The user must then select
an answer. Appropriate user feedback is shown to the user indicating if they
made the right decision. See
questionTransition1(int, ImageView, ImageView, TextView)
and
questionTransition2(int, ImageView, ImageView, TextView)
for more
information about this process. After the feedback has been given, then
running man then moves to the next question. The process is repeated until
question 7. When the running man moves after answering the 7th question, He
runs to the finish line and the final animation occurs. The final animation
is the 'swirling star' (See endAnimation()
for more info) Once the
ending animation is complete, the next buttons are presented to the user to
move to the next screen in the current cycle.
Data collected here includes all answers chosen, how many correct answers were chosen, how long it took the user from the beginning of the screen to make an answer selection for all 7 questions, and the total time the user spent on the screen.
Modifier and Type | Field and Description |
---|---|
(package private) Activity |
activity
The instance of the current Activity
|
(package private) SSCallback |
callback
The instance of the
SSCallback that allows this fragment to
communicate with the parent activity. |
(package private) char[] |
choice
Where the output data is stored indicated if the user selected the
correct answer.
|
(package private) boolean |
done
A boolean value indicating when the user has finished playing the game.
|
(package private) ImageView |
gobutton
The image for the beginning go button.
|
(package private) ImageView |
man0
animated man for different legs in the race in the game
|
(package private) ImageView |
man1
animated man for different legs in the race in the game
|
(package private) ImageView |
man2
animated man for different legs in the race in the game
|
(package private) ImageView |
man3
animated man for different legs in the race in the game
|
(package private) ImageView |
man4
animated man for different legs in the race in the game
|
(package private) ImageView |
man5
animated man for different legs in the race in the game
|
(package private) ImageView |
man6
animated man for different legs in the race in the game
|
(package private) ImageView |
man7
animated man for different legs in the race in the game
|
(package private) ImageView |
man8
animated man for different legs in the race in the game
|
(package private) int |
numcorrect
value of the number of correct answers the user made.
|
(package private) TextView |
q1
TextView for question
|
(package private) TextView |
q1a1
TextView for answer to a question.
|
(package private) TextView |
q1a2
TextView for answer to a question.
|
(package private) ImageView |
q1h
ImageView with the smiley faces.
|
(package private) ImageView |
q1s
ImageView with the smiley faces.
|
(package private) TextView |
q2
TextView for question
|
(package private) TextView |
q2a1
TextView for answer to a question.
|
(package private) TextView |
q2a2
TextView for answer to a question.
|
(package private) ImageView |
q2h
ImageView with the smiley faces.
|
(package private) ImageView |
q2s
ImageView with the smiley faces.
|
(package private) TextView |
q3
TextView for question
|
(package private) TextView |
q3a1
TextView for answer to a question.
|
(package private) TextView |
q3a2
TextView for answer to a question.
|
(package private) ImageView |
q3h
ImageView with the smiley faces.
|
(package private) ImageView |
q3s
ImageView with the smiley faces.
|
(package private) TextView |
q4
TextView for question
|
(package private) TextView |
q4a1
TextView for answer to a question.
|
(package private) TextView |
q4a2
TextView for answer to a question.
|
(package private) ImageView |
q4h
ImageView with the smiley faces.
|
(package private) ImageView |
q4s
ImageView with the smiley faces.
|
(package private) TextView |
q5
TextView for question
|
(package private) TextView |
q5a1
TextView for answer to a question.
|
(package private) TextView |
q5a2
TextView for answer to a question.
|
(package private) ImageView |
q5h
ImageView with the smiley faces.
|
(package private) ImageView |
q5s
ImageView with the smiley faces.
|
(package private) TextView |
q6
TextView for question
|
(package private) TextView |
q6a1
TextView for answer to a question.
|
(package private) TextView |
q6a2
TextView for answer to a question.
|
(package private) ImageView |
q6h
ImageView with the smiley faces.
|
(package private) ImageView |
q6s
ImageView with the smiley faces.
|
(package private) TextView |
q7
TextView for question
|
(package private) TextView |
q7a1
TextView for answer to a question.
|
(package private) TextView |
q7a2
TextView for answer to a question.
|
(package private) ImageView |
q7h
ImageView with the smiley faces.
|
(package private) ImageView |
q7s
ImageView with the smiley faces.
|
(package private) double[] |
random
I don't know what this does.
|
(package private) SSJsonReader |
reader
The instance of the
SSJsonReader class that reads in the dynamic
content for the application. |
(package private) ImageView |
star
The image for the ending animation.
|
(package private) boolean[] |
swappedAnswers
An array indicating that the answer values have been swapped.
|
(package private) boolean |
temp1
boolean value indicating what template this fragment is currently apart
of.
|
(package private) boolean |
temp2
boolean value indicating what template this fragment is currently apart
of.
|
(package private) boolean |
temp3
boolean value indicating what template this fragment is currently apart
of.
|
(package private) SSTimer |
timer
The instance of the
SSTimer used for retrieving timing values for
this Fragment. |
(package private) java.lang.String[] |
times
Array containing times of selections from beginning of screen to the time
of answer selection
|
(package private) boolean |
voComplete
A boolean value indicating when the
voMediaPlayer has finished
playing. |
(package private) MediaPlayer |
voMediaPlayer
The instance of voice over MediaPlayer
|
Constructor and Description |
---|
Game(SSJsonReader reader,
int run)
The constructor saves what template type this Fragment is a part of and
copies the instance of the
SSJsonReader into memory. |
Modifier and Type | Method and Description |
---|---|
private void |
baseQuestionTransition(int index,
TextView firstQuestion,
TextView secondQuestion)
After a answer is selected, this method puts that application into a
state to reflect the selection.
|
private void |
endAnimation()
This method is what causes the star to swirl when the running man arrives
at the finish line.
|
private void |
gameAnimation(int location)
Method call to move the running man to the corresponding question.
|
private void |
hideGoButton()
This method is what causes the go button to fade out when the go button
is pressed at the beginning of the game.
|
void |
onAttach(Activity activity)
This class uses the onAttach method of the android life cycle to save an
instance of the activity and to implement the interface between the main
activity and this fragment activity
|
void |
onClick(View v)
Controls the flow of the game.
|
void |
onCompletion(MediaPlayer mp)
This method changes the value within
voComplete to indicate the
voice over file has finished playing. |
View |
onCreateView(LayoutInflater inflater,
ViewGroup container,
Bundle savedInstanceState)
This method is called by the system to inflate the layout for the Game
screen.
|
void |
onDestroy()
All data is saved within this method and memory with the
voMediaPlayer is released. |
private void |
questionTransition1(int index,
ImageView happy,
ImageView sad,
TextView secondQuestion)
This method is for when the first answer is selected.
|
private void |
questionTransition2(int index,
ImageView sad,
ImageView happy,
TextView secondQuestion)
This method is for when the second answer is selected.
|
Activity activity
SSCallback callback
SSCallback
that allows this fragment to
communicate with the parent activity.char[] choice
boolean done
ImageView gobutton
ImageView man0
ImageView man1
ImageView man2
ImageView man3
ImageView man4
ImageView man5
ImageView man6
ImageView man7
ImageView man8
int numcorrect
TextView q1
TextView q1a1
TextView q1a2
ImageView q1h
ImageView q1s
TextView q2
TextView q2a1
TextView q2a2
ImageView q2h
ImageView q2s
TextView q3
TextView q3a1
TextView q3a2
ImageView q3h
ImageView q3s
TextView q4
TextView q4a1
TextView q4a2
ImageView q4h
ImageView q4s
TextView q5
TextView q5a1
TextView q5a2
ImageView q5h
ImageView q5s
TextView q6
TextView q6a1
TextView q6a2
ImageView q6h
ImageView q6s
TextView q7
TextView q7a1
TextView q7a2
ImageView q7h
ImageView q7s
double[] random
SSJsonReader reader
SSJsonReader
class that reads in the dynamic
content for the application.ImageView star
boolean[] swappedAnswers
boolean temp1
boolean temp2
boolean temp3
SSTimer timer
SSTimer
used for retrieving timing values for
this Fragment.java.lang.String[] times
boolean voComplete
voMediaPlayer
has finished
playing. Default value = false;MediaPlayer voMediaPlayer
public Game(SSJsonReader reader, int run)
SSJsonReader
into memory.reader
- The instance of the SSJsonReader
run
- The integer representation of the corresponding Template the
Fragment is a part of.private void baseQuestionTransition(int index, TextView firstQuestion, TextView secondQuestion)
index
- passed argument to record the time for the corrent question
and animate the running man to the appropriate locationfirstQuestion
- id of TextView to make invisiblesecondQuestion
- id of TextView to make invisibleprivate void endAnimation()
private void gameAnimation(int location)
location
- move the running man to the specified question numberprivate void hideGoButton()
public void onAttach(Activity activity)
public void onClick(View v)
public void onCompletion(MediaPlayer mp)
voComplete
to indicate the
voice over file has finished playing. If the game has been completed, the
Fragment indicates to its parent activity that the next button can now be
visible to the user and the user has completed all required elements
within the Fragment.public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
public void onDestroy()
voMediaPlayer
is released.private void questionTransition1(int index, ImageView happy, ImageView sad, TextView secondQuestion)
numcorrect
is increased. Furthermore, if the answer was correct,
the answers smiley is visible and the incorrect answer is set to
invisible. If the incorrect answer was chosen, then the the incorrect
smiley is shown and the incorrect answer is partially visible.index
- used to determine if the answers were swapped and record the
users responseshappy
- the top smiley in the question setsad
- the bottom smiley in the question setsecondQuestion
- the bottom answer in the question setprivate void questionTransition2(int index, ImageView sad, ImageView happy, TextView secondQuestion)
numcorrect
is increased. Furthermore, if the answer was correct,
the answers smiley is visible and the incorrect answer is set to
invisible. If the incorrect answer was chosen, then the the incorrect
smiley is shown and the incorrect answer is partially visible.index
- used to determine if the answers were swapped and record the
users responseshappy
- the top smiley in the question setsad
- the bottom smiley in the question setsecondQuestion
- the bottom answer in the question set