Week 6 - Format Strings, Custom Views, Sound Files, Touch/Gestures, Game Animation Flashcards
What is the %d token in a format string a placeholder for?
An integer value.
What are format strings used for?
They are used as a template into which additional strings are inserted.
What is the %f token in a format string a placeholder for?
A floating point value.
What is the %s token in a format string a placeholder for?
A string.
What does the “,” flag mean in a format string token?
Grouping separator for large decimal numbers.
What does the “0” flag in a format string token mean?
It controls zero-padding of numbers.
How are format string resources accessed in code?
String s = getResources().getString(R.string.the_format_string, str1, str2);
How is a custom view created?
By extending either the View class or a subclass of the View class and overriding its methods.
What is a SurfaceView?
It provides a flat surface on which things can be drawn and animated frame by frame.
What does the SoundPool class do?
It manages and plays sounds for an app.
What are the three parameters of the SoundPool constructor?
- The maximum number of streams.
- The type of the stream.
- The quality of the audio. (Just use 0.)
How is a sound played via the SoundManager?
By calling its play() method.
How is a sound loaded into SoundPool?
By calling its load() method.
What type of view is typically used for game animation?
SurfaceView, because it can be drawn on and animated on a frame by frame basis.
How does one implement a draw loop to animate a SurfaceView?
A thread can be created that contains a reference to the SurfaceView and a loop that updates what is displayed on the SurfaceView.