mario zechner - beginning android games
TRANSCRIPT
-
^
-
Mario Zechner
Beginning
Android Games
Get started with game apps development for the Android platform
Apress
-
Android
^
- --
2013
-
Android
. . . . , . . . , . .
32.973.2-018.2 004.451
78 A n d r o i d . .: , 2 0 1 3 . 6 8 8 .: .
ISBN 978-5-459-01554-6
, Android. , . , Android. Android. , Android, - . Android, ( , ), . , , , .
ISBN 978-1430230427 . 2011 by Mario Zechner. All rights reservedISBN 978-5-459-01554-6 , 2013
, , 2013
. . ., , , . , , , .
, 198206, -, , 73, . 29. 005-93, 2;
95 3005 . 22.08.12. 70x100/16. . . . 55,470. 1500.
. 180004, , . , 34.
-
.................................................................................................. 16
.................................................................................................. 18
.................................................................... 19
....................................................................................... 20
..................................................................................... 21
1. Android: ....................................................... 22
2. Android S D K ....................................................... 42
3. 1 0 1 ....................................................................67
4. Android ...............................................116
5. Android Game Development Framework.................................... 199
6. Android...............................................246
7. OpenGL ES: .......................................... 288
8. 2 D -n rp .................................................375
9. : , OpenGL E S ...................................................................... 458
10. OpenGL ES: 3 D ....................................................... 522
11. 3D -n rp ...............................................563
12. Droid Invaders: .............................................622
13. ..............................................................673
14. ?.............................................................................684
-
........................................................................................................... 16 ........................................................................................ 16 ................................................................................ 16 .......................................................................... 17
........................................................................................................... 18
.......................................................................... 19
................................................................................................ 20
............................................................................................ 21
1. Android: ......................................................... 22 Android................................................................................23.................................................................................................... 24 Google.................................................................................................... 24
Android Open Source Project............................................................... 25Android Market.................................................................................... 25, Google I/O.................... 26
Android............................................................... 26.................................................................................................. 28 Da lv ik............................................................... 28 ......................................................................28 ......................................................................29
Software Development K it................................................................................30 ............................................................................31, , ! ............................................................. 32
..................................................................32 , , .......... 33
......................................................... 37 ................................................... 38 ..................................................................................39
-
..............................................................................39 , ............................................... 40
.................................................................................................. 41
2. Android S D K ........................................................... 42 ..........................................................................42
JDK....................................................................................43 Android SDK........................................................................43 Eclipse................................................................................44 ADT Eclipse..................................................... 45 Eclipse............................................................. 47
Hello World Android............................................................................49 ..............................................................................49 ........................................................................50 ............................................................. 51
Android........................................................... 54 ....................................................................54 Android.......................................55 ............................................................................56 ..........................................................................59LogCat DDMS.................................................................................... 62 ADB............................................................................64
.................................................................................................. 65
3. 1 0 1 ..........................................................................67: ..................................................................................68
................................................................................68...................................................................................... 70 ....................................................................71 ................................................................................73- ................................................................................74
: ........................................................... 75 ....................................................................76 ........................................................................78 ..................................................................78
: ...................................................................................... 83 ................................................... 84.................................................................................................. 84 -........................................................................88
7
-
8
.....................................................................................................89...............................................................................................93 ..................................................................................... 107
................................................................................................... 115
4. Android ...................................................... 116 Android: ......................................116
.............................................................................118 .........................................................................118 ...............................................................................120 .................................................................122 .......................................................................123 ...........................................................................125 Android 10 ....................125 .................................................... 127
Android API......................................................................................... 128 .............................................................. 129 .............................................................. 133 ................................................................ 140 ............................................................ 157 .................................................................................163 ...............................................................................168 .................................................... 172
............................................................................................. 197 ................................................................................................... 198
5. Android Game Development Fram ework..........................................199 ..................................................................................................... 199 AndroidFilelO.........................................................................................200AndroidAudio, AndroidSound Android Music !............................. 201Androidlnput AccelerometerHandler................................................................ 207
AccelerometerHandler: ?...................................................... 207 Pool: !...................................................... 209KeyboardHandler: , , , , , ................... 211 ........................................................................ 216Androidlnput: ..................................................223
AndroidGraphics AndroidPixmap: ............................................226 ....................... 226AndroidPixmap: ..................................................232
-
9
AndroidGraphics: , ....................................233AndroidFastRenderView: -, -........... 237
AndroidGame: .................................................................... 240 ................................................................................................... 245
6. Andro id .................................................... 246 ......................................................................................... 246 ......................................................................................... 248MrNomGame: .................................................................249
: .............................................. 249:
.......................................................................251LoadingScreen: ................................253
................................................................................................. 255() HelpScreen....................................................................................... 258 ............................................................................................... 260
: .................................................... 261 .............................................................................263
..............................................................................................266 : , , ........ 266 GameScreen...............................................................................279
................................................................................................... 287
7. OpenGL ES: ................................................ 288 OpenGL ES ................................288
: ............................................................ 289............................................................................................. 291 . . . .293............................................................................................. 294 .......................................................................295
................................................................................................. 296GLSurfaceView: 2008 .................................................. 297GLGame: .................................................... 300, : !..........................................308
........................................................ 309 ........................................................ 309 .............................................................. 313 ........................................................................................... 317
...........................................................................321
-
10
: ..............................325
............................................................................. 325
...................................................... 327
............................................................................. 329 ................................................................................. 330
.....................................................................330 .................................................................331
........................................................................................... 331
Texture....................................................................................... 334
: .......................................... 336
........................................................................................... 338
Vertices..................................................................................... 340
-: ...................................................... 343
: , , ...................................... 347
20-: ..............................349 ...............................................................349
................................................................................... 351 ........................................ 352
.......................................................................357
...................................................................361
.................................................................361
Android 1 .5 .......................................... 363
OpenGL ES- ?................................363
............................................ 365
........... 367
OpenGL ES/JNI....................368 ...........................................................369 ..................................................................................... 372
....................................................................................................373
8. 2D -n rp .........................................................375
..................................................................................................375 ....................................................................................... 376
............................................................................. 377
.......................................................................379
Vector.....................................................................381
...........................................................385
-
20-......................................................................................... 390 ........................................................ 390 ....................................................................................... 392 .............................................................. 392 .................................................................393
2 D ..........................398 ...................................................................398 ...................................................... 401 ................................................................ 404 ............................405 .........................................................................412
2 D ................................................................................................... 426 Camera2D...................................................................................430............................................................................................... 431 : ................................................ 433
, : OpenGL ES..........................439 TextureRegion.............................................................................440 SpriteBatcher.............................................................................441 SpriteBatcher.......................................................... 447
-........................................................................................... 451 Animation...................................................................................452............................................................................................... 453
................................................................................................... 457
9. : , OpenGL E S ...............................................................................458 ...........................................................................458 .......................................................................................460 ......................................................................................... 460 ...........................................................................462 ......................................................................................... 465
.......................................... 465 ..............................467 ...................................................................................470 ........................................................ 472 ..................................................................................... 473
.....................................................................473 Assets......................................................................................... 473 Settings..................................................................................... 477
1 1
-
12
........................................................................... 478 Font........................................................................................... 479 G L ..............................................................................................481 ........................................................................... 482 ................................................................................... 485 ...................................................................488 .........................................................491 ..................................................................................... 508 WorldRenderer........................................................................... 516
?.......................................................520 ....................................................................................................521
10. OpenGL ES: 3 D ...............................................................522 ..................................................................................................522 3D..................................................................................................523
Vertices3: -...................................................523................................................................................................526
: , .......................................................529Z-: ............................................................................. 532
...........................................................533
: ...........................................................535 z- z-.............................................................538
30-................................................................................... 540: Hello World 3D ........................................................................... 540................................................................................................543
................................................................... 547 ................................................................................... 547
........................................ 550 ....................................................................... 557
....................................................................................................562
11. - .......................................................563 ..................................................................................................563 3 D ..................................................................................................564 OpenGL E S ................................................................................. 569
..................................................................... 569 ......................................................................... 571..........................................................................................572
-
OpenGL ES : ................. 573 ......................................................................................... 574 OpenGL E S ...............................589
Mip-....................................................................................... 590 ............................................................................................. 595
( )............................595 .................................................. 599 .........................................................605
........................................................................................... 607 Wavefront O BJ.........................................................................608 OBJ...................................... 609 OBJ Loader...................................................... 614 ........................................ 615
3 D ..................................................................................... 615 3 D ..........................616
3D............................................................617 ....................................617 GameObject3D DynamicGameObject3D..................................619
................................................................................................... 620
12. Droid Invaders: ................................................... 622 ...............................................................................622 ............................................................ 624 ......................................................................................... 624 ...........................................................................626 ......................................................................................... 627
.............................................. 627 ................................................................................. 629 ..................................................................................... 631
............................................................................................. 631 Assets....................................................................................................631 Settings..................................................................................................635 ....................................................................................... 636 ..................................................................................... 637 ............................................................................................... 640 ............................................................................................. 643
Shield......................................................................................... 644 Shot........................................................................................... 644
13
-
14
Ship........................................................................................... 645 Invader.......................................................................................647 World......................................................................................... 651
GameScreen...........................................................................................657 World Renderer.......................................................................................665................................................................................................... 671 ................................................................................................... 672
13. .................................................................... 673 ...................................................................... 673 ............................................674 - .............................................................. 675 Android Market................................................................ 679
...............................................................................680 ...............................................................................680 .........................................................................681!......................................................................................... 681...........................................................................................682
.....................................................................................682 ................................................................................................... 683
14. ?.....................................................................................684 ...............................................................................684 ........................................................................ 684 .................................................... 685OpenGL ES 2.0 .....................................................................................685 .....................................................................................685 .................................................................................687 .......................................................................................687
-
Android. , 14 . , Android, , , .
: Android, , , OpenGL ES. , 3D.
, , . , , . . , , , .
. , - . . ( ) Java. Android Eclipse !
, Android. . , . Android , .
, , ( ). , . , ,
-
17
, . , , , .
; . Eclipse . , , , . Eclipse . ( ) , , .
, Google Code, . GPL 3,
Subversion . ,
Eclipse, , . ,
. Subversion. , , () , .
, . , , . , , Subversion
Eclipse. , . 5 6 ch06-mrnom.
Google Code-npoeKT http://code.google.com /p/beginning- android-games.
-
06
R&D, . Badlogic Games. Newton Android, Quantum Windows, Linux Mac OS X, . , libgdx. , . , ( h t tp : / / www.badlogicgames.com/wordpress).
-
, , . Battery Powered Games. Android, Deadly Chambers, Antigen, Wixel, Light Racer Light Racer 3D. , , IBM Interactive. , .
-
, . , , , . , , . , , . , , .
, . , . , , , .
, , , . , , , , - 1^1; . , .
, , , , , . , . !
-
, [email protected] ( , ).
! http://www.piter.com
.
-
1 Android: 1990-, Nintendo Game Boy. , , RC Pro-Am . , . . PC, , Game Boy. . Game Boy ...
2010 . , N intendo DS Playstation Portable. , , . iOS Apple . , , Apple , . Android . - . , , . - , , .
, , Android PC . Android. , , , !
, Android.
-
Android 23
Android Android 2005 , Google - Android, Inc, Google . 2008 Android 1.0, Android . iOS ( iPhone OS) Blackberry, .
Android , . . , Android , .
Android Open H andset Alliance ( ) 2007 . , , Qualcomm, M otorola NVIDIA, . Android Google, .
Android, , ( ) , Linux 2.6, . Android (U ser Interface, UI), Sense M otorola M OTOBLUR. Android . , ROM. , Cyanogen, Android-.
2008 Android , - ( Android 1.1). , . 1.5 (Cupcake) Android Java. , . 1.6 (D onut) . , Android. 2.0 (Eclair) -, 2.2 (Froyo) (Just-in-Time, J IT ) Dalvik, Jav a- Android. J IT
-
24 1. Android:
Android . 2.3 (Gingerbread), Dalvik. , , Android- Java.
2011 Android , Honeycomb 3.0. , . 3.0 , . Android 2.3 , . , Gingerbread, Nexus S, Google.
Android : , , . , , , , Android. , , .
. , Android. . , . , , , (, ). .
. , , , . , Android. , API. , , iOS ( ). , Android.
Google Android Open Handset Alliance, Google , .
-
Google 25
Android Open Source Project Google Android Open Source Project. Apache License 2 ( , , GNU General Public License (G PL)). . , Android, Android Compatibility Program , , , . Android, Android M arket1.
Android MarketAndroid M arket 2008 Google. - , . , .
.
Google. 15 , . 24 , .
, , Google Android. $25 . .
Android M arket , . , . , , . . . . , ( W indow s-) . Android ; Android M arket .
Google Checkout M erchant ( ). .
1 Android Market Google play (play.google.com). , Android Market Google play. . .
-
26 1. Android:
, Google I/O
Android , Google . , Android Developer Challenge (ADC), 2008 . . ADC , . 2010 ADC , , Android .
, Google 2010 . , ( ) 5000 3,5 , Motorola Droid, Motorola Milestone Nexus One. , . . , , Google .
Google Android Dev Phone (ADP). ADP T-Mobile G l ( Dream). , ADP 2, Magic, Google (Nexus One) . , ADP 2. Google Nexus One , . 2010 ADP. Samsung, Android 2.3 (Gingerbread), Nexus S. A DP- Android Market ( ). , Nexus S Google ( www.google.com/phone).
Google I/O , Android , . Google, Android . Google I/O , Android; YouTube ( Google Developer).
AndroidAndroid Linux . Android , , Linux. , Android , Java. Android
-
Android 27
. -, , API , , , . -, Dalvik, Android. , 2D- -, - (Ogg Vorbis, MP3, MPEG-4, .264, PNG), API , GPS, , , , . API , . Android- . , Android . .
Android . . . 1.1 Android.
X J L
J 3
I
I ( ^I I I
SurfaceManager
Open GL I ES
SGL
MediaFramework
FreeType
SQLite
WebKit
SSL libc
Android
Dalvik
Linux
J
Wi-Fi
J D
-
J ( IPC)
. 1.1. Android
-
28 1. Android:
, Linux . , , , . .
Dalvik Android, , Android. Dalvik.
Dalvik - DEX. Jav a- CLASS DEX dx, SDK. DEX , CLASS, , CLASS-. Dalvik , Java-nporpaMM. , , Java SE, Apache Harmony. , Java SE Dalvik Swing Abstract W indow Toolkit, Java ME. ( ) Java SE Dalvik.
Android 2.2 (Froyo) . Froyo J IT -, - . , . J IT - , , (Floating Point Unit, FPU).
, Dalvik (Garbage Collector, GC). , . , . Android (2.3) GC, . GC .
, Dalvik, 16 24 . , .
, Java SE, C /C ++ , ( , . 1.1).
-
Android 29
( , , ), Dalvik. API Java , . . Skia Graphics Library (Skia) 20-
Android. 2D-iirpbi.
OpenGL for Embedded Systems (OpenGL ES) . OpenGL ES 1.0 1.1 Java Android. OpenGL ES 2.0, , Android 2.2 (Froyo). , Java- OpenGL ES 2.0 . , (, , ) OpenGL ES 2.0. OpenGL ES 1.0 1.1, .
- . (Ogg Vorbis, MP3, H.264, M PEG-4 . .). , Java , .
FreeType ( TrueType). FreeType , . , Java, . , FreeType Java , .
. , Java.
--------------------------------------------------------------------------------------------- Dalvik , . - . . Android, Java. http://code.google.eom/p/libgdx/ .
, Android. , .
-
30 1. Android:
Java, , , , , , . . , Android (, ), API.
, , . . , . , . (, ). , Android.
. , , . , .
Software Development Kit Android Android Software Development Kit (SDK). , , , . Java-, Android API . .
SDK : , ,
; ,
; , QEM U (
, ), , ;
; .
SDK Eclipse (ID E ) Java. Android Development Tools (ADT), Eclipse Android, , Android Market.
-
31
, SDK IDE (, NetBeans), .
--------------------------------------------------------------------------------------------- 2 SDK Eclipse.
SDK ADT Eclipse , . .
SDK . Android SDK . , API http://developer.android. com/guide/index. html.
Android , . Android Developers, http://groups.google.com/group/ android-developers. , ( ) . Android, . Google, Android. , . . , , , .
. Linux , GNU , ... , Mozilla Firefox . Android . . , 1.2 .
. 1.2. Android
-
32 1. Android:
, Android. Replica Island , Google .
, , !Android . , , Motorola Samsung, , . , Android. , .
Android- . Google , ( ) Android- .
ARM - CPU , Android 86. ARM .
128 . high-end 512 , 1 .
256 - . Android, . Froyo.
Mini SD Micro SD , .
16- TFT LCD HVGA 1.6 Android HVGA- (480 320 ). 1.6 . WVGA- (800 480, 848 480 852 480 ), QVGA (320 280
-
, , ! 33
). , .
. , , . .
, Android . GPS, . . ( ). QW ERTY- ( ).
. : , ( ). (G PU ). Android- , OpenGL ES 1.0. GPU, Xbox PlayStation 2 OpenGL ES 2.0. PixelFlinger. , .
Android- . - - (.264).
, W i-Fi Bluetooth. (SoC); .
, ,
( ), Android- , . , Android. .
, , / . , Android, .
-
34 1. Android:
: Android. .
Android, iPhone. 2009 1.5, . Android 2.1. root . 3,2- VGA-, / Qualcomm 528 MSM7201A, , , 5- . - , , .
. (, ). , - ( API 1.5). , , iPhone.
480 320 ( 1.6).
( ), MSM7201A ot Qualcomm, ( ). MSM7201A OpenGL ES 1.0, . , iPhone 3G PowerVR MBX Lite ( ). , Dream (T-Mobile G l). MSM7201A , 3D- . , Android.
, : 500
; ( M SM 7201A),
OpenGL ES 1.x; 480 320 ; ; Android 1.5/1.6 .
-
, , ! 35
, . , , , , . , .
: 2009 . Motorola Droid Nexus One ( 2010) . Nexus One Qualcomm QSD8250 ( 1 ) Snapdragon. Motorola Droid 34 (550 ) Texas Instruments. Vector Floating Point (V FP) NEON ARM . Nexus One 512 , Motorola Droid 256 .
W VGA- 800 480 , Active-Matrix Organic Light-miting Diode (AMOLED) ( Nexus One) LCD 854 480 ( Motorola Droid). . , , .
Nexus One Android 2.1, M otorola Droid 2.0. Android 2.2. . PowerVR SGX530 , iPhone 3GS. , iPhone 3GS , Motorola Droid, Apple ( ). Adreno 200, Nexus One ( Qualcomm), , PowerVR SGX530. , MSM7201A.
: 550 1
; OpenGL ES 1.x 2.0; W VGA-; ; Android 2.0, 2.0.1, 2.1 2.2.
-
36 1. Android:
, 2.1, , , , . , (, ).
2010 ( Evo Samsung i9200 Galaxy S). Nexus One Motorola Droid , .
: , . , , . Samsung i9200 Galaxy S2, AM OLED- 1280 720, 2 1 . NVIDIA egra 2, .
Android, -. , Android. Android (, 86) , . Android 3.0. , Android !
Android, . API , SDK, .
Zeemote JS1 (. 1.3) .
Bluetooth. API, Zeemote SDK. Android .
-
37
. 1.3. Zeemote JS1
Nintendo W ii ( Bluetooth). , Wii, SDK .
Game Gripper , M otorola D roid M ilestone. , QW ERTY- - . Gripper. , .
Android. , . .
, iPhone Android . . .
-
38 1. Android:
, . . , , . , .
. , . . , , .
, . , , .
. . (, ), . , .
, : , . - , , USB-, .
. , , Xbox PlayStation 2. , . .
, . GPS / , Android-. , - . ( W ii)
-
39
. , .
, . , . ( ).
. , . , .
. 1 . (, Xbox PlayStation 2), , Febook Twitter, . , .
, , NES, . . , , . - , Alt+Tab , .
: , ? , - ? , , , Dungeons & Dragons . iPhone Android , . ,
1 Twitter (twitter.com). . .
-
40 1. Android:
: , . : - , . . , !
, . Android SDK . , ( ). Android . . .
, , . ( ). Gameloft . iPhone, Android Android M arket. Gameloft ( A ndroid) .
, ( ). (P C ) . Android M arket , , .
, , . . Android .
Android Market. , , . . , , , . . , -.
-
41
Android . , , . Android (, , SDK). , . ( , ) . . ? !
-
2 Android SDKAndroid SDK . Android . .1. .
2. Eclipse .3. .
4. . .
--------------------------------------------------------------------------------------------- Web , URL-. , , .
Android SDK . . , , IDE ( ).
, :
Java Development Kit (JD K ), 5 6; ;
Android Software Development Kit (Android SDK); Eclipse Java, 3.4 3.5;
Android Development Tools (ADT) Eclipse.
, .
-
43
JDK JD K . , . JD K JDK_H0ME, JDK. , $JDK_H E/bin (%JDK_HOME%\bin W indows) PATH.
Android SDKAndroid SDK . SDK ZIP TAR GZIP. (, c:\android-sdk W indows /opt/android-sdk Linux). SDK , tool s. ANDROID_H0ME, SDK, SANDROID_H0ME/tool s (XANDROID_HOMEX\tool s W indows) PATH. .
, , Android, SDK and AVD manager ( SDK ). , . SDK and AVD manager, ( Linux). . Android. Android
SDK, , .
SDK. , . API Google .
USB Windows. W indows. Mac OS X Linux .
. . .
. API Android.
-
44 2. Android SDK
, , , . SDK and AVD manager. W indows SDK manager.exe, SDK. Linux OS X android, tool s SDK.
SDK and AVD manager - . , , 2.1, . Accept All ( ) Install (), .
v>+ C liu u ie P d c k d g n tu lii>ldU Packoges
v SDK Platform Android 2.2, API 8, revision 2 (x]
v SDK Platform Android 2.1, API 7, revision 2 [x]
v SDK Platform Android 2.0.1, API 6, revision 1...
v SDK Platform Android 2.0, API 5, revision 1 (...
v SDK Platform Android 1.6, API 4, revision 3 [x] i
v SDK Platform Android 1.5, API 3, revision 4 PI
v SDK Platform Android 1.1 API 2. revision 1 (...
V SMnfifes fnr SDK API R. rpvismn 1
Sample? for SDK API 7, revision 1 ? Google APIe by Google Inc., Android API 8, r...
? Google API3 by Google Inc., Android API 7, r...
? Google ATI* by Google Inc., Android API C. r...
? Guuyfe APIs by Guuyle Inc., A n Ju id API 0, 1...
Package Description St License
P a c k a g e D escrip tion aAndroid b U K Hlattorm Z^_rl R ev is ion 2
DependenciesThis package is a dependency for boogie A H s by Uoogle Inc., Android A M , revision 2
A rc h iv e D e tc tip lio nArchive foe Windows Size: 73 MiSHA1 : e80ddc2f8f9929bc8d46bc579be86d43317adb57
Sitehttns/VHI-ssI rmnnlft rnm/flnrlrnirl/rpnnsitnruAftnnsnru ml
Accept O H eject Q Accept AI
\ Instal I I Cancel ]
. 2.1. SDK and AVD manager
SDK and AVD manager , . AVD, .
.
EclipseEclipse . Android Eclipse for Java Developers 3.6. Android SDK, Eclipse ZIP TAR GZIP. . eel ipse , .
-
45
. . 2.2 .
W o r k s p a c e L a u n c h e r S e l e c t a w o r k s p a c e
E c lip se stores your projects in a folder ca lled a w orkspace.
C h o o s e a w o rkspace folder to u se for this session.
W o rk s p a ce : C A D cum ent s and Settings\mzechner\workspace| v-| [ Brow se... J
1 1 U s e this a s the default and do not a s k again
O K 1 I C a n ce l
. 2.2.
Eclipse , . . -, , , . - .
Eclipse , . Java- . Eclipse . , .
ADT Eclipse ADT Eclipse. , . ADT Android SDK Eclipse. Android SDK ADT Eclipse.
Eclipse ( Z IP - Eclipse), . , , .
1. Help Install New Software ( ), . . ,
-
46 2. Android SDK
ADT. Add (), , , 2.3.
#= Add Repository
Nam e: |
Location : http://
Loca l...
\ Archive...
C a n c e l
. 2.3.
2. ( - ADT repos i tory). URL- . ADT : https://dl-ssl.google.com/android/eclipse/. , , ADT.
3. , . Developer Tools ( ) Next ().
4. Eclipse , , , . Next ().
5. , . , , , Finish ().
--------------------------------------------------------------------------------------------- . , , . .
6. Eclipse . . Restart Now ( ) .
Eclipse, . , Android , SDK and
-
47
AVD manager Eclipse, Android. . 2.4.
. 2.4. ADT
AVD and SDK Manager. Android-. - ( ).
ADT Android SDK.1. Window Preferences ( )
Android .2. Browse (), ,
Android SDK.3. . ,
Android-.
EclipseEclipse IDE, . , Eclipse, Java. Eclipse , C /C ++, Scala Python. ; , , ( , ).
Eclipse , . , ( , , ).
(U I) : , (,
, ); ,
(, , , , , . .).Eclipse Java .
Java Debug (). Java . 2.5. Package Explorer ( ) , ( ,
-
48 2. Android SDK
), , Outline () , Problems ( ), Javadoc Declaration ().
Java - Eclipse
File Ed it R un S ou rce R e fa cto r N av igate S ea rch Project W indow Help
r:- s ( a ^ ji- ft
. 2.5. Eclipse Java
, . , . , Window Show View ( ) - , Other (), . Window Open Perspective ( ) , . Eclipse. , . .
, . 2.5, . . , ADT ? : . ADT DDMS ( Android Java Debug
-
Hello World Android 49
()). , ADT , Log Cat ( ).
Eclipse . , Android. , , Eclipse - . .
Hello World Android , , , Android-npo- Eclipse. ADT , Android .
A ndroid-. Package Explorer ( ) (. . 2.5) New Project ( ) . Android Project ( Android) Android. , . Eclipse. Android. : Android- (. . 2.4).
Android .1. .
. hei 1 worl d.2. . Android 1.5
, .
--------------------------------------------------------------------------------------------- 1 , Android API. , , , API . , Android 2.3, . : - (, Android 1.5), API, 2.3, . . , , 5, .
-
50 2. Android SDK
3. (, hei 1 worl d), Java, (, com.helloworld), . Android . Hel 1 oWorldActivity.
4. Android, . Min SDK Version ( SDK). , . SDK 1 (1.0) . 1.5 , 3. , , , SDK. API, , , (, , , API ).
Finish () Android.
--------------------------------------------------------------------------------------------- SDK . Android, SDK, . Android Market , , SDK.
Package Explorer ( ) , hei 1 worl d. , , . 2.6. Android-. . Androi dMani f e s t . xml . ,
, Android (, ).
default, properties . ADT .
src/ Java. , .
gen/ Java, Android. , .
-
Hello World Android 51
P a c k a g e Explorer
%
-
52 2. Android SDK
. Package Explorer ( ). 2.1.
2.1. HelloWorldActivity.java package com.helloworld;
import android.app.Activity; import android.os.Bundle; import android.view.View; import android.widget.Button;
public class HelloWorldActivity extends Activity
implements View.OnClickListener {Button button; int touchCount;
@0verridepublic void onCreate(Bundle savedlnstanceState) {
super.onCreate(savedlnstanceState); button = new Button(this); button.setText( "Touch me!" ); button.setOnCli ckLi stener(this); setContentView(button);
}
public void onClick(View v) { touchCount++;button.setText("Touched me " + touchCount + " time(s)");
2.1, , . . , , .
^- . , Android, android:
package com.helloworld;
import android.app.Activity; import android.os.Bundle; import android.view.View; import android.widget.Button;
HelloWorldActivity Activity, API Android. Activity , -,
-
Hello World Android 53
, ( Android).
, OnCl i ckLi stener. , , , :
public class Hel 1oWorldActivity extends Activityimplements View.OnClickListener {
: Button , :
Button button;int touchCount;
Act i v i ty Act i v i ty. onCreate(), . , . onCreate () :
@0verridepublic void onCreate(Bundle savedlnstanceState) {
super.onCreate(savedlnstanceState);
Button . Button , API Android. , Android. Hell oWorl dActi v i ty. :
button = new Button(this); button.setText( "Touch me!" );
onCreate () OnCl i ckLi stener Button. OnCl ickListener , OnCl i ckLi stener. onCl i ck (), . , Hel 1 oWorl dActi vi ty OnCl i ckLi stener Button:
button.setOnCli ckLi stener(this);
onCreateO Button . , . Button , .
-
54 2. Android SDK
, .
setContentView(button);}
OnClickListener.onCl i ck(), , Acti vity. , . touchCount .
public void onClick(View v) { touchCount++;button.setText("Touched me" + touchCount + "times");
}
hello world, , , Button. , . , , . . ADT Eclipse , , . , . bi / . Android- .
Android , , ( ). : ,
USB-; , SDK, .
, .
, . Windows , SDK, . Windows, driver/ SDK.
-
Android 55
. Linux Mac OS X . Linux ( udev). - .
AndroidSDK , Android (AVD). Android, , , . . AVD SDK and AVD manager. SDK , Eclipse, SDK manager ( ) .1. Virtual Devices ( ) .
. SDK manager, ; .
2. AVD New () . (. 2.7).
? C re a te n e w A n d r o id V ir tu a l D e v ic e (A V D ) X
Name:
T arget:
SD Card:
0 Size: | MiB [v]
File: I I I Browse... |
Built-in:
Resolution: [ 1 x I
Hardware:
Property
I I Override the existing A V D with the same name
Cancel
. 2.7. AVD SDK manager
-
56 2. Android SDK
3. ( Name ( )), . Target () Android, AVD. , AVD, . hei 1 worl d Android 1.5, . , .
--------------------------------------------------------------------------------------------- Android , .
AVD . Eclipse hei 1 worl d Package Explorer ( ) Run As Android Application ( Android) ( Run () ). .1. (
).2. Android
( ).3.
Android ( Min SDK Version ( SDK) ). AVD Android 1.5 ( ),
ADT Eclipse , hei 1 worl d . , . 2.8.
, , , . . .
, . (, Android Market). .
7 . 7, Num Lock.
-
Android 57
1 2 3 4 5 6 7 8 9 0Q W R V I S D F G J L
Z X V N J @ _ /
MINU
&
-
58 2. Android SDK
Eclipse, , . , , ( H a ja v a SE) . . Eclipse . ADT . Eclipse ADT Android Application Run .
, .1. Package Explorer
( ) Run As Run Configurations ( ).
2. hel 1 world .3. ,
Android, Target () Commons tabs ( ).
4. Target ( ) Manual ().
. . 2.9. , .
A n d r o id D e v ic e C h o o s e r X
Select a device compatible with target Android 1.5.
() Choose a running Android device
Serial Number A V D Nam e Target D ebug State
^ emulator-5554 android! .5 v Android 1.5 Y e s Online
H T97JL901589 N/A 1.5 Online H T 0103703 N/A 2.2.1 Online
Launch a new Android Virtual D eviceA V D Name Target Name Platform API Level I Details...
android2.2 Android 2.2 2.2 8I Start...
I Refresh
I Manager...
QK I I Cancel ]
. 2.9. /
-
Android 59
, AVD, .
. , . Eclipse ADT Android. , , .
, AndroidManifest.xml. , . , . . XML- . :
androi d : debuggable="true"
. , Android Market.
, , . . , Eclipse , . 23 Hel 1 oWorl dActi vity. . , (. 2.10). , .
5 0 p u b l i c v o i t ! o n C l i c k (V ie w v ) { t o u c h C o u n t+ + ;b u t t o n . s e t T e x t ( " T o u c h e d m e ,,+ t o u c h C o u n t + ,r t irtie ( s ) " ) ;
}}____________________________________________
. 2.10.
, . Package Explorer ( ) Debug As Android Application ( Android). ( , ). , Debug As Debug Configurations ( ) .
-
60 2. Android SDK
--------------------------------------------------------------------------------------------- Package Explorer ( ) Run () , .
, Eclipse , Debug (), . . . 2.11 hei 1 worl d.
f D eb u g - lieUu vui ld/>i u /u u in /lte tlu w u i Id/H eU uW ui IdA uliv ily .je . X
File Edit Run Source Navigate Search Project Refactor Window Help
: J Q ) : f i J u ^ O * 4 T & 12$ ^ w B j [ Debug | Java
: J I I 11 i ] - 51 O * H I
* DD s. ? j> 3 S ? Ihellu wui Id [Ar hJi uid Appkcdiur i]!
3' Dah/ikVM(tocalhost:86CO] i p Thiead [ main] (Running); Thiead k 15> Binder Thiead 31 fRunninol
:
W= Variables I Breakpoints & 0 '
[|j default.properties j [7) HelloWorlcWctrvity javaLiuttuu. seLTexU ( "Tuuch ine ! " ) ; b u t to n .s e to n e l ic k L 1 s t e n e r ( t h i s ) ; se tc o n te n tv ie w (b u tto n );
}A - p u b l i c v o i d o n C l ic k ( V ie w v ) (
to u c h C o u n t+ + ; b u t t o n . 3 e tT e x t ( "T o u c h e d me " -ftouchC
}}
J
Oudine! com. hclloworid
2 import decJaration-s
0 I IdoVorldActivity buUuri. Bulluri
touchCount int
w onCieate(Bundte) void
a onClck(View) void
@ Console 3 ] Tasks i 51 cf 5 . = ]Android[2010-10-12[2010-10-12[2010-10-12[ZUIU-IU-IZ
22:03:59 - 22:04:18 - 22:04:18 - ZZH341Z -
helloheliuhellohellohello
woulcTJ WUL 111]world]world]woriaj
Uploading 1 A Ins Lctl 1 iny Success! Starting ac Attempting r_n
< 1 JUL 1
------- 'S-i f f LogCat c'-lLog
T i e p i d t a g M e ssa g e [*] U - I* 1 : b b . 64 d a lv ik v m H e a p W o rk e^ j
< i 1 1 >
I amrhinrj h#lln wrvlrl
. 2.11. Debug ()
Eclipse, , , . Debug () Run ().
, , Debug () . , .
-
Android 61
Debug () , Java.
Console () ADT, , .
Log Cat . , , . , , . Log Cat .
Outline () . , , , . Debug (), .
Variables () . , .
, Breakpoints ( ) .
, , , , . 23 . , Variables () , ( th is ) (v). , .
Debug () , . : , Debug (). , , , .
( F6), , ( F5), ( F8). , Run (). , , . , , .
--------------------------------------------------------------------------------------------- Android-. , . Eclipse, .
-
62 2. Android SDK
LogCat DDMS ADT Eclipse. ( ) LogCat.
LogCat Android, . , , , ID - , ( ) .
LogCat . . 2.12 LogCat.
LogLdt LogTine pid tag Message10-13 23 16 D dalvikvm GC (xccd 1231 ubjouts s 49136 byt..10-13 23:16 D 119 dalvikvm GC freed 949 objects / 35712 byte10 13 23:16. D 212 dalvikvm CC freed 1480 objects / 70632 byt...10-13 23:18 D 69 Keygu... receive ACTION_BATTERY_CHANGED10-13 23:18 D 69 HtcLo. onRefreshBatterylnfo: 4510-13 23.18 I 69 H Il-Lu . . . updaleSlViewByPi'iuii ty10-13 23:18 I 69 HtcLo .. crea t eDevlceSt a t usView10 13 23:18.. D 295 UobCo ACTION_BATTERY_CHAHCED10-13 23:18 D 295 UsbCo .. unplugged 210-13 23:18 D 295 UsbCo USB Connected10-13 23.18 D 295 UsbCo... ObexServciSlArled-true10-13 23:18 D 295 UsbCo jAtCoandServerStar ted true10 13 23:18.. D 295 UobCo Shov Notification ..10-13 23:18 I 124 Conta... android.intent action.NOTIFICATIO...10-13 23:20 .. . I 9195 jdwp received file descriptor 24 from ADB10-13 23.20... 9195 Sysle... Cant dispatch DDM chunk 46454154
. 2.12. LogCat
LogCat. ,
. ,
, ID , . , (, , ).
, . /, LogCat
. , DDMS.
DDMS (D alvik Debugging M onitor Server) Dalvik, . DDMS Window Open Perspective Other DDMS (
-
Android 63
). . 2.13 , .
_ XFdc Edit Rcfoctor Ren Navigate Scorch Projcct Window Hdp
a ** Jv d < 4 V ' '< *
& (Q a j ] I 'w 1 DDMS H Debug Ja
Dovecs ^
8
bac 9195
019 0 rin e 1138 %
liL
&-
Q E n x ia ta Control i
elephon^ Statut
L
"% Thrcod* S3 H Alocoton T rocker Fte Explorer
T eleohorty Actions
Inrhmmgniimfwr Voice
V
ID TkJ S lotus UIIC vtiiie Nome1 1198 woi 63 15 moin*2 1199 vmwait 2 0 HeapWockef3 1200 vmwait 0 0 Signal Catcher4 1201 luriMig 1 0 JDWP5 1202 vmwait 7 11 Comoilef6 1203 rvjtrvc 0 0 Binder Thread 817 1204 native 0 0 Binder Thread 29 1206 nabve 33 0 android hardware Sem orM anagerSemorT bread
I Refreth I
Class
>= LogCat IZ
LogT in e p id ta g M essag e10-13 23 31 dalvikvrn GC_EXPLICIT fxccii 6493 ubjculs /*
I-
. 2.13. DDMS
, , . , , , , Log Cat . . . Devices ()
, . : , , .
LogCat , : , Devices ().
Emulator Control ( ) . , , - GPS- .
-
64 2. Android SDK
Threads () , , Devices (). , ( , Devices ()).
Heap () ( . 2.13) . , Devices () .
Allocation Tracker ( ) . .
File Explorer ( ) A ndroid- . , .
DDMS , Eclipse ADT. $AN DR0ID_H / tools directory (%ANDROID_HOME%/tools Windows). , Android Debug Bridge (ADB) , SDK. , Android.
ADBADB . .
, adb ( , ). ADB, .
, . ADB .
ADB, . ADB .
ADB DDMS, . , .
--------------------------------------------------------------------------------------------- ADB Android Developers (http://developer.android.com).
-
65
, ADB, ADB- ( , ) . ( : > ):
> adb devices
:
List of devices attached HT97JL901589 device HT019P803783 device
. , - myapp. 019803783:
> adb -s 019803783 in sta ll myapp.apk
-s ADB, - .
(). myf i 1 . tx t 019803783:
> adb -s 019803783 push m yfile.tx t /sdcard/m yfile.txt
myfi 1 . tx t , :
> abd pull /sdcard/m yfile.txt m yfile.txt
ADB- , adb .
, ADB . DDMS, . .
Android . , , , .
-
66 2. Android SDK
, , . JD K Android SDK Android. , . Eclipse ADT, JD K SDK . Eclipse : , ; , (, Log Cat); , (, ); , .
, . , Android. , .
, , , : .
-
3 101 . - , - , , . , -, , . ! , . : , . , ? ?
, : , . - , , . ( , ). . ? ? ? ? ? ? ?
, . , . . , , . , . , .
-
68 3. 101
: , , . - , , , . ( , . .) - . , , / / .
Android Market.
, Android M arket . ? , . ( ), . ( , ). (-) ( ). - .
Abduction Abduction 2 (. 3.1 ), Psym Mobile, . ( ). . , . . : /. , Android Market.
Antigen (, 3.2) Battery Powered Games . , . . , . , , . Abduction, , Antigen . , ( Zeemote).
-
: 69
. 3.1. Abduction () Abduction 2 () Psym M obile
. 3.2. Antigen Battery Powered Games
320 240.
. , Android Market.
-
70 3. 101
. , - Bejeweled. Android . PC, Android 3 , .
Super Tumble (. 3.3). , , , . , . Box2D 2-.
. 3.3. SuperTum ble Camel Games
U Connect BitLogik , (. 3.4). . .
. 3.4. U Connect BitLogik
-
: 71
, Android M arket , 3 . , , 20- .
Android. -, . (, , - ).
Replica Island , - Android (. 3.5). Google - , Java Android. . Replica Island . , . 16- SNES. ( , ). .
* 0 * * 0
S 99
. 3.5. Replica Island
ExZeus HyperDevBox Starfox SNES - (. 3.6). : , , , . 3D-nrp, ExZeus
-
72 3. 101
. .
. 3.6. ExZeus HyperDevBox
Deadly Chambers Battery Powered Games , Max Payne Tomb Rider (. 3.7). Dr. Chambers . Battery Powered Games . , , , , ? . , . . ExZeus, , . , , . , , , .
Radiant Hexage Space Invaders (. 3.8). , , .
-
: 73
. 3.7. Deadly Chambers Battery Powered Games
, , , . , .
1
f t
. 3.8. Radiant
Android, . , .
-
74 3. 101
, Android.
- // / . , . , . , .
Robo Defense Lupis Labs Software Android (, 3.9). . , . , . , , , , .
. 3.9. Robo Defense Lupis Labs Software
- - Android (, GPS) . , .
SpecTrek Android Developer Challenge (, 3.10). GPS .
-
: 75
, Catch () .
- A
3 S f t
mHold phone flat (like a map) for radt mode.
. 3.10. SpecTrekking.com
, , Android, Android M arket , . ( , , , . .). , , , . . , .
.
: , IDE . - . . , , . . . : ; ; ; ,
(, ).
-
76 3. 101
, , Android- (Snake). . , , ...
, . , , , . . .
, . :
;
-, ;
.
. Paint, Gimp Photoshop, . , . , .
. . 3.11 , .
-
: 77
( Nexus One). . , . , , ? , ( ) , . 3.12 .
: , , . , . . 90 . , . , 10, . .
, ? , . , , . , . : .
-
78 3. 101
, , .
, , , , . . 3.12, . . .
, , , . , !
, . , .
, : . . . . , , , .
. 3.13 , . , .
. 3.13. , ,
, , , . . , . ,
-
: 79
(, , , ). (, , ). . (, New Game ( ) ). , .
, , , . ? , . , , . , , PLAY ( ) ( ). , (HIGHSCORES), . , , , (HELP) . , . / .
. , (Human Computer Interfaces, HCI), . . , 3.14.
: f [
(h)
\
. 3.14.
-
80 3. 101
(, . .) . , . , . ( ) .
. , . , . , . 3.15. ( ) , , . .
. . . , : ; , ; ( , ). , . 3.16. , , .
. -, , . , -
-
: 81
I
.
U l _
. 3.16.
. , , . ; .
, . . Resume ( ) . , .
, . G a m e Over ( ) . .
, , , . : , , . . 3.17 .
. , . , . , . . .
! , ? 3.18 . .
-
82 3. 101
. 3.17.
. 3.18.
-
: 83
, . .
-------------------------------------------------------------------------------------------------------------------, , . , . , , . , . - , .
: , , Android A P I . , . , . . , Android. : , , (, 2 0 - O p e n G L ES).
, . . ' . ,
/ Android. .
(, ). /. ,
. , , , .
. . , . .
. ,
, ( Android).
------------------------------------------------------------------------------------------------------------------- . . , . , (www.gamedev.net ).
-
84 3. 101
.
, , , ( , ). , , .
( ). , - . And roid , ( ) .
, , , . , ( O p e n G L ES).
- . . , :
Create () ( , );
Pause () - ;
Resume ( ) .
------------------------------------------------------------------------------------------------------------------- Android . ( Android)? , ? , . , Android Android. .
, - . . ( )
-
: 85
. , . . , , . A P I , . ? .
. . . , . , .
. , . , . .
? Android : , / . . . :
, ; , .
;
, . :
( - - ).
:
; .
. , - . : (, Shift). , . , .
, . . -, ., z (. 3.19).
-
86 3. 101
. 3.19. Android; o cb z
(/2). , 9,8 / 2. . , . , . . , , 9,8 / 2. . 3.19 , , .
, , , ( 3.1 ).
3.1. Input KeyEvent TouchEvent package .badlogi .androi dgames.framework;
import java.util.List;
public interface Input {public static class KeyEvent {
public static final int KEY_D0WN = 0; public static final int KEY_UP = 1;
public int type; public int keyCode; public char keyChar;
}
public static class TouchEvent {
-
: 87
public static final int T0UCH_D0MN = 0;public static final int TOUCH_UP = 1;public static final int TOUCH_DRAGGED = 2;
public int type; public int x, y; public int pointer;
}
public boolean isKeyPressedCint keyCode);
public boolean isTouchDown(int pointer);
public int getTouchXCint pointer);
public int getTouchYCint pointer);
public float getAccelXO:
public float getAccelYO:
public float getAccelZO:
public List getKeyEventsO:
public List getTouchEventsO;}
KeyEvent TouchEvent. KeyEvent , KeyEvent; TouchEvent . KeyEvent , - ( KEYJJP).
TouchEvent TouchEvent, , ID , . I D , . ID, 0, 1 . . 0 , ID 1 , . , 0.
Input, . Input.isKeyPressedO keyCode . Input.isTouchDownO, Input.getTouchXO Input.getTouchYO , .- /-. , .
-
88 3. 101
Input.getAccelX(), Input.getAccelYO Input.getAccelZO .
. KeyEvent TouchEvent, , . .
, . .
------------------------------------------------------------------------------------------------------------------- , : -, Dalvik ( ); -, . , , .
- . , Java, InputStream OutputStream Java- . (, , ). , , , , . , , 3.2.
3.2. FilelOpackage .badlogi .androi dgames.framework;
import java.io.IOException; import java.io.InputStream; import java.io.OutputStream;
public in te rface FilelO {public InputStream readAsset(String fileName) throws IOException;
public InputStream readFi1e(String fileName) throws IOException;
public OutputStream w riteFile(String fileName) throws IOException;}
. . , Java
-
: 89
IOExcepti on. , , , . - SD- ( ).
InputStreams OutputStreams Java. , .
, . ; , ( , ).
, , , .
, . , . , . , , , , . , , . , , , . . , . , , .
: , , . , , , , .
, . : . , , - . . , .
-
90 3. 101
. , . , . . , (). , . - 44 100 (44,1 ). ( 8 ).
, . . , . , . , . : 8-, 16- 32- 32- ( 64-) . . , 8- -128 127.32- i nteger . f 1 oat , -1 1. . . .
(), . , . , , . , . , .
-, . , , , . , , , . , , !
-
: 91
, . ? , , , . , . .
, 60 : 8 8 44 16 . , ? 1 . 8000 8000 . 60- 480 000 , 0,5 . , : 2 , 2 44 000 . 88 000 . 60 5 280 000 ( 5 ). - 15 ( , ). ?
, . , . . , , , .
? , , , . .
, . , , . , . (, ) . .
-
92 3. 101
. , .
, . : ; ; .
Audi , Mus i Sound ( 3.3-3.5 ).
3.3. Audiopackage com.badlogi .androi dgames.framework :
public in te rface Audio {public Music newMusi (String filename):
public Sound newSound(String filename):}
Audio Music Sound. Mus i , Sound , . Audi . newMusi () Audi . newSound ( ) IOException (, ). , .
3.4. Musicpackage com.badlogi .androi dgames.framework :
public in terface Music {publ ic void playO :
publ ic void stopO :
publ ic void pauseO :
publ ic void setLooping(boolean looping)
publ ic void setVolume(float volume):
publ ic boolean isPlayingO :
publ ic boolean isStoppedO:
publ ic boolean isLoopingO :
pub lic void disposeO :
-
: 93
Music . , , ( ). , oat 0 () 1 (). , Music. Music , , .
3.5. Soundpackage com.badlogi .androi dgames.framework;
public in te rface Sound {public void pi ay ( f l oat volume);
public void disposeO ;}
Sound, , . , , ! (), float. ! () , (, ). Sound , .
------------------------------------------------------------------------------------------------------------------- , . , . , . . , .
, , . , , , ( ) . , , . 2).
, , ? , , .
, . , . ,
-
94 3. 101
. , . , , .
: . . , . , , . . , . . , .
, , - , (0; 0). (1; 0), (0; 1) . . ( . 3.20). , . ( , ). . 1, 1. - , , ( ).
(0 : 0) ( 1:0 ) (2 ; 0)
( 1: 1) (2 ; 1)
color[] vram = new color[3*2];
vram[0] vram[1] vram[2] vram[3] vram[4] vram[5]
(0 ;0) (1,0) (2;0) (0 :1) (1:1) (2:1)
. 3.20. VRAM
. , . ( , ). - 60 ; - .
, ( 11). 11, , , .
-
: 95
, . , . - , VRAM.
, . ( VRAM RAM) - . . ? . 3.20 3 x 2 , VRAM (, VRAM ). , . .
in t address = + * rasterWidth;
, . :
in t = address % rasterWi dth: in t = address / rasterWidth;
, - VRAM. - , . , , , . VRAM, .
--------------------------------------------------------------------------------------------- , , , , . . . , . . , , .
, , , . . , VRAM, , -. , . , ( ).
. ,
-
96 3. 101
(G PU ) . . , . GPU , . API , , .
: , . ( vsync). , . GPU , .
, . VRAM , . API, . API (, OpenGL ES) , VRAM . , , . , ( ), , , . vsync , , - .
API , U I- . , . , . , . , .
?, , , . col or , 3.20 , . , .
-
: 97
. . 400 700 . , , ( , ). . . : , (, ). (, - ). , . , . , , , , , , . , . .
, , (, RGB). RGB Red (), Green (), Blue (). (, YUV CMYK). API RGB , , , .
RGB - , (, , ). , , . 3.21 RGB.
, , . 3.21, , . 0 (, 1). , (. 3.22). . (, , ), 0 1. , 0,0 , 1,0 . (0; 0; 0), (1; 1; 1).
-
3. 101
. 3.21.
. 3.22.
-
: 99
RGB ? , . 0,0 1,0. . , (3 4 8 , 32- 64- ). , . . 0 255. 3 , 24 , , 2 24- (16 777 216) . , .
? , . 16- , 2 . 5 , 6, 5 . , , , , . 2 16- (65 536) . . 3.23 .
float: (1,0; 0,5; 0,75)24- : (255; 128; 196) = 0xFF80C4 16- : (31; 31; 45) = OxFCOD
. 3.23. ( - , , )
flo a t 32- Java. 24- : Java 24- integer, byte, 32- i nteger, 8 . 16- , short. , Java , .
16-, 24- , short integer. : RGB BGR. . 3.23 RGB-. 5 8 , 6 8 , 5 8 . BGR- ,
-
100 3. 101
. RGB- , API Android .
, . 32- RGB- fl oat 12 ,
0,0 1,0. 24- RGB- i nteger 3 4 ,
0 255. RGB BGR. RGB888 BGR888, 8 .
16- RGB- integer 2 ; 0 31, 0 63. RGB BGR. RGB565 BGR565, 5 6 . . ,
, , . 24 , . . , , .
--------------------------------------------------------------------------------------------- . RGB , . , .
, (, Gimp, Pain.NET Photoshop). . ? ?
-, , . , . , RGB888 (24 ). , 1024 1024 . 3 ! RGB565 , 1 .
, . , . JP E G PNG. JP E G . ,
-
: 101
, . PNG , . , , .
, . 20 , .
, ( , - ). RAM, . , ., , , .
- , . : API.
- , : . , , , , . , 3.24 , -.
. 3.24. ,
-
102 3. 101
, , . , . , ? . 3.25.
| |
. 3.25.
, . . 3.24 . , . , , ?
-. - - ( -). RGB- , ( ). , , .
, 24- RGB- 32- i nteger. 8 , . 0 ( ) 255 (). ARG