关闭

关闭

关闭

封号提示

内容

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

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

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

shippou890
2011-09-19 0人阅读 0 0 0 暂无简介 举报

简介:本文档为《Android系统游戏开发入门手册(1)pdf》,可适用于IT/计算机领域

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:ADOpenGLESGameForyourconvenienceApresshasplacedsomeofthefrontmattermaterialaftertheindexPleaseusetheBookmarksandContentsataGlancelinkstoaccessthemivContentsataGlanceContentsvAbouttheAuthorxiiAbouttheTechnicalReviewerxiiiAcknowledgmentsxivIntroductionxv■Chapter:Android,theNewKidontheBlock�■Chapter:FirstStepswiththeAndroidSDK�■Chapter:GameDevelopment�■Chapter:AndroidforGameDevelopers�■Chapter:AnAndroidGameDevelopmentFramework�■Chapter:MrNomInvadesAndroid�■Chapter:OpenGLES:AGentleIntroduction�■Chapter:DGameProgrammingTricks�■Chapter:SuperJumper:ADOpenGLESGame�■Chapter:OpenGLES:GoingD�■Chapter:DProgrammingTricks�■Chapter:DroidInvaders:theGrandFinale�■Chapter:PublishingYourGame�■Chapter:What’sNext�IndexxvIntroductionHithere,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,moreadvancedsections■INTRODUCTIONxviGettingtheSourceCodeThisbookisfullyselfcontainedallthecodenecessarytoruntheexamplesandgamesisincludedHowever,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)

关闭

新课改视野下建构高中语文教学实验成果报告(32KB)

抱歉,积分不足下载失败,请稍后再试!

提示

试读已结束,如需要继续阅读或者下载,敬请购买!

评分:

/49

意见
反馈

立即扫码关注

爱问共享资料微信公众号

返回
顶部

举报
资料