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.
What does the onTouchEvent() callback do?
It is called when a a touch event was not intercepted by any of the over views that are currently active.
What is the main limitation of the onTouchEvent callback?
It only executes in response to simple touch events such as taps and drags, but not sequences of events like double taps. It would register a double tap as two single taps.
What does a SimpleOnGestureListener do?
It contains methods that are executed in response to various touch gestures on the screen.
How does a SimpleOnGestureListener receive a touch event?
A touch event has to be explicitly passed to its onTouchEvent() method. This can be done in the onTouchEvent() callback.
How does a touch event listener indicate that it has intercepted the touch event?
By returning true.