资源描述:
《猴子吃香蕉游戏的实现.doc》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、HowToBuildaMonkeyJumpGameUsingCocos2D,PhysicsEditor&TexturePackerPart3TweetIfyou'renewhere,youmaywanttosubscribetomy RSSfeed orfollowmeon Twitter.Thanksforvisiting! Thisisapostbyspecialcontributor AndreasLoew,thecreatorofTexturePackerandPhysicsEditor.Createt
2、hisverticalscrollingplatformerwithCocos2D!WelcometothefinalpartoftheMonkeyJumptutorial!Inthisseries,wearecreatingafunverticalscrollingplatformerwithCocos2D, TexturePacker and PhysicsEditor.In PartOne onthetutorialseries,weintroducedtheMonkeyJump!gamedesign,c
3、reatedthespritesheetsandshapesweneeded,andbegancodingthegame.In PartTwo,weaddedourherotothegame,madehimmoveandjump,andaddedsomegameplay.Inthisthirdandfinalpartoftheseries,wewilladdsomeperformanceimprovements,addaHUDLayer,andyes–killthemonkey!:]We’llbestartin
4、gwiththeprojectwhereweleftofflasttime.Ifyoudon’thaveitalready,grabthe sourcecode forthistutorialseriesandopenup5-MonkeyJumpAndRun.Allright,timetostopmonkeyingaroundandwrapupthistutorial!:]TooManyObjects!Playingourgameforawhile,you’llseethatitgetsslowerandslo
5、wer,untilitbecomescompletelyunplayable.There’sareasonforthis–asobjectscontinuetofallfromthesky,oneafteranother,theybumpintotheobjectsalreadylyingaround.AllofthesecollisionshavetobehandledbyBox2d.Iftherearenobjects,therearen*(n-1)possiblecollisionstohandle.Bo
6、x2duseshashestomakethingsfaster,butyoucanimaginehowdramaticallythenumberofcollisionsincreasesasthenumberofobjectsincreases.Ifyouwatchastatuedrop,you’llseethatnearlytheentirestackbelowmovesandbouncesfromimpulsespassedfromthestatuedownthroughthestackfromoneobj
7、ecttoanother.Toimprovethesituation,we’regoingtoconvertobjectswhicharesomedistancebelowthemonkeyintostaticobjects.Thesestaticobjectswillstillletotherobjectspileupabovethem,butthey’llnolongerreacttotheimpact.Asaresult,afallingstatuewillonlyaffectthetopofthesta
8、ckinsteadofthecompletepile.Box2dallowsobjectstogotosleepwhentheyaren’ttouchedbyotherobjectsforsometime.Wewillusethisfeaturetoimproveperformance.GB2Enginehasaniteratemethodthatcanbeusedtoiteratea