Week 6 - Format Strings, Custom Views, Sound Files, Touch/Gestures, Game Animation Flashcards

0
Q

What is the %d token in a format string a placeholder for?

A

An integer value.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
1
Q

What are format strings used for?

A

They are used as a template into which additional strings are inserted.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is the %f token in a format string a placeholder for?

A

A floating point value.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is the %s token in a format string a placeholder for?

A

A string.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What does the “,” flag mean in a format string token?

A

Grouping separator for large decimal numbers.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What does the “0” flag in a format string token mean?

A

It controls zero-padding of numbers.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How are format string resources accessed in code?

A

String s = getResources().getString(R.string.the_format_string, str1, str2);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

How is a custom view created?

A

By extending either the View class or a subclass of the View class and overriding its methods.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is a SurfaceView?

A

It provides a flat surface on which things can be drawn and animated frame by frame.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What does the SoundPool class do?

A

It manages and plays sounds for an app.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What are the three parameters of the SoundPool constructor?

A
  1. The maximum number of streams.
  2. The type of the stream.
  3. The quality of the audio. (Just use 0.)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

How is a sound played via the SoundManager?

A

By calling its play() method.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

How is a sound loaded into SoundPool?

A

By calling its load() method.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What type of view is typically used for game animation?

A

SurfaceView, because it can be drawn on and animated on a frame by frame basis.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

How does one implement a draw loop to animate a SurfaceView?

A

A thread can be created that contains a reference to the SurfaceView and a loop that updates what is displayed on the SurfaceView.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What does the onTouchEvent() callback do?

A

It is called when a a touch event was not intercepted by any of the over views that are currently active.

16
Q

What is the main limitation of the onTouchEvent callback?

A

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.

17
Q

What does a SimpleOnGestureListener do?

A

It contains methods that are executed in response to various touch gestures on the screen.

18
Q

How does a SimpleOnGestureListener receive a touch event?

A

A touch event has to be explicitly passed to its onTouchEvent() method. This can be done in the onTouchEvent() callback.

19
Q

How does a touch event listener indicate that it has intercepted the touch event?

A

By returning true.