关闭

关闭

关闭

封号提示

内容

首页 Android系统游戏开发入门手册(1)

Android系统游戏开发入门手册(1).pdf

Android系统游戏开发入门手册(1)

shippou890 2011-09-19 评分 0 浏览量 0 0 0 0 暂无简介 简介 举报

简介:本文档为《Android系统游戏开发入门手册(1)pdf》,可适用于IT/计算机领域,主题内容包含CHAPTER:SuperJumper:ADOpenGLESGameBeginningAndroidGamesofferseverythingyou符等。

CHAPTER:SuperJumper:ADOpenGLESGameBeginningAndroidGamesofferseverythingyouneedtojointheranksofsuccessfulAndroidgamedevelopersYou’llstartwithgamedesignfundamentalsandprogrammingbasics,andthenprogresstowardcreatingyourownbasicgameengineandplayablegamesThiswillgiveyoueverythingyouneedtobranchoutandwriteyourownAndroidgamesBeginningAndroidGameswillguideyouthroughtheprocessofmakingsomegreatgamesfortheAndroidplatform,andyou’llsoonfindyourselfactivelycodingandcreatinggames,acrossthesetopics:•SetupandusetheAndroiddevelopmenttools:getreadytowriteyourowngames•ClassicDgameprogramming:buildaddictiveactionandplatformgamesofyourown•Androidgraphicsandaudio:makeyourgameslookandsoundgorgeous•Gamemechanics:usecollisiondetection,physics,andspriteanimationtodeadlyeffect•Dgameprogramming:addcomplexDtoyourgamestheeasyway•Thefinalyard:publishyourgame,getcrashreports,andsupportyourusersAllyouneedisabasicknowledgeofJavaandthedesiretowriteawesomemobilegamesBeginningAndroidGameswillhelpyoukickstartyourprojecttobethenextbreakthroughAndroidgameBeginningAndroidGamesMarioZechnerGetstartedwithgameappsdevelopmentfortheAndroidplatformCHAPTER:SuperJumper:ADOpenGLESGameForyourconvenienceApresshasplacedsomeofthefrontmattermaterialaftertheindexPleaseusetheBookmarksandContentsataGlancelinkstoaccessthemivContentsataGlanceContentsvAbouttheAuthorxiiAbouttheTechnicalReviewerxiiiAcknowledgmentsxivIntroductionxvChapter:Android,theNewKidontheBlockChapter:FirstStepswiththeAndroidSDKChapter:GameDevelopmentChapter:AndroidforGameDevelopersChapter:AnAndroidGameDevelopmentFrameworkChapter:MrNomInvadesAndroidChapter:OpenGLES:AGentleIntroductionChapter:DGameProgrammingTricksChapter:SuperJumper:ADOpenGLESGameChapter:OpenGLES:GoingDChapter:DProgrammingTricksChapter:DroidInvaders:theGrandFinaleChapter:PublishingYourGameChapter:What’sNextIndexxvIntroductionHithere,andwelcometotheworldofAndroidgamedevelopmentMynameisMarioI’llbeyourguideforthenextfourteenchaptersYoucameheretolearnaboutgamedevelopmentonAndroid,andIhopetobethepersonwhoenablesyoutorealizeyourideasTogetherwe’llcoverquitearangeofmaterialsandtopics:Androidbasics,audioandgraphicsprogramming,alittlemathandphysics,andascarythingcalledOpenGLESBasedonallthisknowledgewe’lldevelopthreedifferentgames,oneevenbeingDGameprogrammingcanbeeasyifyouknowwhatyou’redoingThereforeI’vetriedtopresentthematerialinawaythatnotonlygivesyouhelpfulcodesnippetstoreuse,butactuallyshowsyouthebigpictureofgamedevelopmentUnderstandingtheunderlyingprinciplesisthekeytotacklingevermorecomplexgameideasYou’llnotonlybeabletowritegamessimilartotheonesdevelopedoverthecourseofthisbook,butyou’llalsobeequippedwithenoughknowledgetogototheWeborthebookstoreandtakeonnewareasofgamedevelopmentonyourownAWordAbouttheTargetAudienceThisbookisaimedfirstandforemostatcompletebeginnersingameprogrammingYoudon’tneedanypriorknowledgeonthesubjectmatterI’llwalkyouthroughallthebasicsHowever,IneedtoassumealittleknowledgeonyourendaboutJavaIfyoufeelrustyonthematter,I’dsuggestrefreshingyourmemorybyreadingtheonlineeditionofThinkinginJava,byBruceEckel(PrenticeHall,),anexcellentintroductorytextontheprogramminglanguageOtherthanthat,therearenootherrequirementsNopriorexposuretoAndroidorEclipseisnecessary!ThisbookisalsoaimedattheintermediatelevelgameprogrammerthatwantstogetherhandsdirtywithAndroidWhilesomeofthematerialmaybeoldnewsforyou,therearestillalotoftipsandhintscontainedthatshouldmakereadingthisbookworthwhileAndroidisastrangebeastattimes,andthisbookshouldbeconsideredyourbattleguideHowThisBookIsOrganizedThisbooktakesaniterativeapproachinthatwe’llslowlybutsurelyworkourwayfromtheabsolutebasicstotheesotericheightsofhardwareacceleratedgameprogramminggoodnessOverthecourseofthechapters,we’llbuildupareusablecodebase,soI’dsuggestgoingthroughthechaptersinsequenceMoreexperiencedreaderscanofcourseskipcertainsectionstheyfeelconfidentwithJustmakesuretoreadthroughthecodelistingsofsectionsyouskimoveralittle,soyouwillunderstandhowtheclassesandinterfacesareusedinsubsequent,moreadvancedsectionsINTRODUCTIONxviGettingtheSourceCodeThisbookisfullyselfcontainedallthecodenecessarytoruntheexamplesandgamesisincludedHowever,copyingthelistingsfromthebooktoEclipseiserrorprone,andgamesdonotconsistofcodealone,butalsohaveassetsthatyoucan’teasilycopyoutofthebookAlso,theprocessofcopyingcodefromthebook'stexttoEclipsecanintroduceerrorsRobert(thebook’stechnicalreviewer)andItookgreatcaretoensurethatallthelistingsinthisbookareerrorfree,butthegremlinsarealwayshardatworkTomakethisasmoothride,IcreatedaGoogleCodeprojectthatoffersyouthefollowing:•Thecompletesourcecodeandassets,licensedundertheGPLversion,availablefromtheproject’sSubversionrepository•AquickstartguideshowingyouhowtoimporttheprojectsintoEclipseintextualform,andavideodemonstrationforthesame•Anissuetrackerthatallowsyoutoreportanyerrorsyoufind,eitherinthebookitselforinthecodeaccompanyingthebookOnceyoufileanissueintheissuetracker,IcanincorporateanyfixesintheSubversionrepositoryThiswayyou’llalwayshaveanuptodate,(hopefully)errorfreeversionofthisbook’scodefromwhichotherreaderscanbenefitaswell•AdiscussiongroupthatisfreeforeverybodytojoinanddiscussthecontentsofthebookI’llbeonthereaswellofcourseForeachchapterthatcontainscode,there’sanequivalentEclipseprojectintheSubversionrepositoryTheprojectsdonotdependoneachother,aswe’lliterativelyimprovesomeoftheframeworkclassesoverthecourseofthebookEachprojectthereforestandsonitsownThecodeforbothChaptersandiscontainedinthechmrnomprojectTheGoogleCodeprojectcanbefoundathttp:codegooglecompbeginningandroidgamesChapterAndroid,theNewKidontheBlockAsakidoftheearlynineties,InaturallygrewupwithmytrustyNintendoGameBoyIspentcountlesshourshelpingMariorescuetheprincess,gettingthehighestscoreinTetris,andracingmyfriendsinRCProAmvialinkcableItookthisawesomepieceofhardwarewithmeeverywhereandeverytimeIcouldMypassionforgamesmademewanttocreatemyownworldsandsharethemwithmyfriendsIstartedprogrammingonthePCbutsoonfoundoutthatIcouldn’ttransfermylittlemasterpiecestotheGameBoyIcontinuedbeinganenthusiasticprogrammer,butovertimemyinterestinactuallyplayingvideogamesfadedAlso,myGameBoybrokeFastforwardtoSmartphonesarebecomingthenewmobilegamingplatformsoftheera,competingwithclassicdedicatedhandheldsystemssuchastheNintendoDSorthePlaystationPortableThatcaughtmyinterestagain,andIstartedinvestigatingwhichmobileplatformswouldbesuitableformydevelopmentneedsApple’siOSseemedlikeagoodcandidatetostartcodinggamesforHowever,Iquicklyrealizedthatthesystemwasnotopen,thatI’dbeabletosharemyworkwithothersonlyifAppleallowedit,andthatI’dneedaMactodevelopfortheiOSAndthenIfoundAndroidIimmediatelyfellinlovewithAndroidItsdevelopmentenvironmentworksonallthemajorplatforms,nostringsattachedIthasavibrantdevelopercommunityhappytohelpyouwithanyproblemyouencounteraswellascomprehensivedocumentationIcansharemygameswithanyonewithouthavingtopayafeetodoso,andifIwanttomonetizemywork,IcaneasilypublishmylatestandgreatestinnovationtoaglobalmarketwithmillionsofusersinamatterofminutesTheonlythingIwasleftwithwasactuallyfiguringouthowtowritegamesforAndroidandhowtotransfermyPCgamedevelopmentknowledgetothisnewsystemInthefollowingchapters,IwanttosharemyexperiencewithyouandgetyoustartedwithAndroidgamedevelopmentThisisofcoursearatherselfishplan:Iwanttohavemoregamestoplayonthego!Let’sstartbygettingtoknowournewfriend:AndroidCHAPTER:Android,theNewKidontheBlockABriefHistoryofAndroidAndroidwasfirstpubliclynoticedinwhenGoogleacquiredasmallstartupcalledAndroid,IncThisfueledspeculationthatGooglewantedtoenterthemobilespaceIn,thereleaseofversionofAndroidputanendtoallspeculation,andAndroidbecamethenewchallengeronthemobilemarketSincethen,it’sbeenbattlingitoutwithalreadyestablishedplatformssuchasiOS(thencallediPhoneOS)andBlackBerry,anditschancesofwinninglookrathergoodBecauseAndroidisopensource,handsetmanufacturershavealowbarrierofentrywhenusingthenewplatformTheycanproducedevicesforallpricesegments,modifyingAndroiditselftoaccommodatetheprocessingpowerofaspecificdeviceAndroidisthereforenotlimitedtohighenddevicesbutcanalsobedeployedtolowbudgetdevices,thusreachingawideraudienceAcrucialingredientforAndroid’ssuccesswastheformationoftheOpenHandsetAlliance(OHA)inlateTheOHAincludescompaniessuchasHTC,Qualcomm,Motorola,andNVIDIA,whichcollaboratetodevelopopenstandardsformobiledevicesAlthoughAndroid’scoreisdevelopedmainlybyGoogle,alltheOHAmemberscontributetoitssourceinoneformoranotherAndroiditselfisamobileoperatingsystemandplatformbasedontheLinuxkernelversionandisfreelyavailableforcommercialandnoncommercialuseManymembersoftheOHAbuildcustomversionsofAndroidfortheirdeviceswithmodifieduserinterfaces(UIs)forexample,HTC’sHTCSenseandMotorola’sMOTOBLURTheopensourcenatureofAndroidalsoenableshobbyiststocreateanddistributetheirownversionsofAndroidTheseareusuallycalledmods,firmwares,orROMsThemostprominentROMatthetimeofthiswritingwasdevelopedbyafellowknownasCyanogenandisaimedatbringingthelatestandgreatestimprovementstoallsortsofAndroiddevicesSinceitsreleasein,Androidhasreceivedsevenversionupdates,allcodenamedafterdesserts(withtheexceptionofAndroid,whichisirrelevantnowadays)EachversionhasaddednewfunctionalitytotheAndroidplatformthathasrelevanceinonewayoranotherforgamedevelopersVersion(Cupcake)addedsupportforincludingnativelibrariesinAndroidapplications,whichwerepreviouslyrestrictedtobeingwritteninpureJavaNativecodecanbeverybeneficialinsituationswhereperformanceisofupmostconcernVersion(Donut)introducedsupportfordifferentscreenresolutionsWewillrevisitthisfactacoupleoftimesinthisbookbecauseithassomeimpactonhowweapproachwritinggamesforAndroidWithversion(Éclair)camesupportformultitouchscreens,andversion(Froyo)addedjustintime(JIT)compilationtotheDalvikvirtualmachine(VM),whichpowersalltheJavaapplicationsonAndroidTheJITspeedsuptheexecutionofAndroidapplicationsconsiderablydependingonthescenario,uptoafactoroffiveAtthetimeofthiswriting,thelatestversionis,calledGingerbreadItaddsanewconcurrentgarbagecollectortotheDalvikVMIfyouhaven’tnoticedyet:AndroidapplicationsarewritteninJavaAspecialversionofAndroid,targetedattablets,isalsobeingreleasedinItiscalledHoneycombandrepresentsversionofAndroidHoneycombisnotmeanttoCHAPTER:Android,theNewKidontheBlockrunonphonesatthispointHowever,somefeaturesofHoneycombwillbeportedtothemainlineofAndroidAtthetimeofthiswriting,Androidisnotavailabletothepublic,andnodevicesonthemarketarerunningitAndroidcanbeinstalledonmanydevicesusingcustomROMsTheonlyhandsetusingGingerbreadistheNexusS,adeveloperphonesoldbyGoogledirectlyFragmentationThegreatflexibilityofAndroidcomesataprice:companiesthatopttodeveloptheirownuserinterfaceshavetoplaycatchupwiththefastpaceatwhichnewversionsofAndroidarereleasedThiscanleadtohandsetsnotolderthanafewmonthsbecomingoutdatedreallyfastascarriersandhandsetmanufacturersrefusetocreateupdatesthatincorporatetheimprovementsofnewAndroidversionsThebigbogeymancalledfragmentationisaresultofthisprocessFragmentationhasmanyfacesFortheenduser,itmeansbeingunabletoinstallandusecertainapplicationsandfeaturesbecauseofbeingstuckonanoldAndroidversionFordevelopers,itmeansthatsomecarehastobetakenwhencreatingapplicationsthatshouldworkonallversionsofAndroidWhileapplicationswrittenforearlierversionsofAndroidwillusuallyrunfineonnewerversions,thereverseisnottrueSomefeaturesaddedinnewerAndroidversionsareofcoursenotavailableonolderversions,suchasmultitouchsupportDevelopersarethusforcedtocreateseparatecodepathsfordifferentversionsofAndroidButfearnotAlthoughthissoundsterrifying,itturnsoutthatthemeasuresthathavetobetakenareminimalMostoften,youcanevencompletelyforgetaboutthewholeissueandpretendthere’sonlyasingleversionofAndroidAsgamedevelopers,we’relessconcernedwithdifferencesinAPIsandmoreconcernedabouthardwarecapabilitiesThisisadifferentformoffragmentation,whichisalsoaproblemforplatformssuchasiOS,albeitnotaspronouncedThroughoutthisbook,IwillcovertherelevantfragmentationissuesthatmightgetinyourwaywhileyoudevelopyournextgameforAndroidTheRoleofGoogleAlthoughAndroidisofficiallythebrainchildoftheOpenHandsetAlliance,GoogleistheclearleaderwhenitcomestoimplementingAndroiditselfaswellasprovidingthenecessaryecosystemforAndroidtogrowTheAndroidOpenSourceProjectGoogle’seffortsaresummarizedunderthenameAndroidOpenSourceProjectMostofthecodeislicensedunderApacheLicense,averyopenandnonrestrictivelicensecomparedtootheropensourcelicensessuchastheGNUGeneralPublicLicense(GPL)EveryoneisfreetousethissourcecodetobuildtheirownsystemsHowever,systemsthatareclaimedtobeAndroidcompatiblefirsthavetopasstheAndroidCompatibilityCHAPTER:Android,theNewKidontheBlockProgram,aprocessensuringbaselinecompatibilitywiththirdpartyapplicationswrittenbydeveloperslikeusCompatiblesystemsareallowedtoparticipateintheAndroidecosystem,whichalsoincludestheAndroidMarketTheAndroidMarketTheAndroidMarketwasopenedtothepublicinOctoberbyGoogleIt’sanonlinesoftwarestorethatenablesuserstofindandinstallthirdpartyapplicationsThemarketisgenerallyaccessibleonlythroughthemarketapplicationonadeviceThissituationwillchangeinthenearfuture,accordingtoGoogle,whichpromisesthedeploymentofadesktopbasedonlinestoreaccessibleviathebrowserThemarketallowsthirdpartydeveloperstopublishtheirapplicationseitherforfreeoraspaidapplicationsPaidapplicationsareavailableforpurchaseinonlyaboutcountriesSellingapplicationsasadeveloperispossibleinaslightlysmallernumberTable–showsyouthecountriesinwhichappscanbeboughtandsoldTable–PurchaseandSellingOptionsperCountryCountryUserCanPurchaseAppsDeveloperCanSellAppsAustraliaYesYesAustriaYesYesBelgiumYesYesBrazilYesYesCanadaYesYesCzechRepublicYesNoDenmarkYesYesFinlandYesYesFranceYesYesGermanyYesYesHongKongYesYesHungaryYesYesIndiaYesYesIrelandYesYesCHAPTER:Android,theNewKidontheBlockCountryUserCanPurchaseAppsDeveloperCanSellAppsIsraelYesYesItalyYesYesJapanYesYesMexicoYesYesNetherlandsYesYesNewZealandYesYesNorwayYesYesPakistanYesNoPolandYesNoPortugalYesYesRussiaYesYesSingaporeYesYesSouthKoreaYesYesSpainYesYesSwedenYesYesSwitzerlandYesYesTaiwanYesYesUnitedKingdomYesYesUnitedStatesYesYesUsersgetaccesstothemarketaftersettingupaGoogleaccountApplicationscanbeboughtonlyviacreditcardatthemomentBuyerscandecidetoreturnanapplicationwithinminutesfromthetimeofpurchasingitandwillreceiveafullrefundPreviously,therefundtimewindowwashoursTherecentchangetominuteshasnotbeenwellreceivedbyendusersDevelopersneedtoregisteranAndroidDeveloperaccountwithGoogleforaonetimefeeof$inordertobeabletopublishapplicationsonthemarketAftersuccessfulCHAPTER:Android,theNewKidontheBlockregistration,adevelopercanimmediatelystarttopublishanewapplicationinamatterofminutesTheAndroidMarkethasnoapprovalprocessbutreliesonapermissionsystemAuserispresentedwithasetofpermissionsneededbyanapplicationbeforetheinstallationoftheprogramThesepermissionshandleaccesstophoneservices,networkingaccess,accesstotheSecureDigital(SD)card,andsoonOnlyafterauserhasapprovedthesepermissionsistheapplicationinstalledThesystem

用户评论(0)

0/200

精彩专题

上传我的资料

每篇奖励 +1积分

资料评分:

/49
仅支持在线阅读

意见
反馈

立即扫码关注

爱问共享资料微信公众号

返回
顶部

举报
资料