[iPhone-cocos2d]如何执行cocos2d官方自带test文件夹下面程序
Arguably the most unknown cocos2d feature is the tests/samples.
cocos2d contains almost a test for each feature that it has. These tests are grouped by component. eg:
- Sprite Test: It tests the
CCSprite
andCCSpriteSheet
functionality like anchorPoint, visibility, parenting, reordering, honor Transform, etc… - Action Test: It tests the
CCMove, CCRotate, CCTint, CCCamera, CCSequence, CCSpawn
, etc.. - Menu Test: It tests all kind of menus
- CocosDenshion: It tests the Sound Engine
- Chipmunk Accel Touch Test: It tests integration with Chipmunk physics engine using accelerometer and multi touches.
- Particle Test: It tests all kind of particles (quad particles, point particles, sun, meteor, galaxy, smoke, fire, etc…)
- etc…
Although these tests were coded for testing purposes they can also be used as examples. Not only they use the API in the recommended way, but some of them, also contain useful tips in the commentaries.
In order to run the tests, you should do:
- Open the cocos2d Xcode project
- Select the test target: Xcode -> Project -> Set Active Target -> eg: TransitionTest
- Make sure that the running executable is correct: Xcode -> Project -> Set Active Executable -> eg: TransitionTest
- Build and run: Xcode -> Build and run
Another quick way of doing it by customizing the toolbar:
- Xcode -> Right click on the toolbar -> Customize Toolbar
- Drag & drop the Active Target button to the toolbar
- Drag & drop the Active Executable button to the toolbar
The source code of the samples are in the tests subdirectory.
So, let’s say you want to learn how to use Tiled maps. What you should do is:
- Select the TileMapTest target
- Make sure that the TileMapTest executable is selected
- Build & Run.
- Try all the subtests. The TileMapTest has more than 10 subtests. Eg: Hexagonal test, Isometric test, Orthogonal tests, read-write tile tests, etc…
- See the TileMapTest source code: tests/TileMapTest.m
- Modify the source code and go to step 2.
作者:Alexliu(alex dotNet Learning)
出处:http://alexliu.cnblogs.com/
本文版权归作者和博客园共有,欢迎转载,转载请注明。并且保留文章链接。否则保留追究法律责任的权利。
最近常常有朋友问起,如何学习cocos2d,其实最好的文档莫过于官方的wiki,以及一些他所自带的例子。很多朋友不知道如何运行起来,其实cocos2d的博客上早就有了介绍了,步骤就那么5,6步而已,暂时不翻译了。挺简单的,贴过来加个中文的名字,至少搜索这个,就知道怎么弄了。还有就是推荐读那几个开源的游戏喽。不明白的翻我博客,本人曾翻译过很多cocos2d的wiki,希望能有所帮助吧。
http://alexliu.cnblogs.com