a) Cocos2d-iphone引擎利用XCode编写,所以开发者必须有一台拥有mac系统的电脑,以及苹果发布证书。
b) 该引擎仅支持object-c语言。所以开发者必须有扎实的object-c语言基础。另外,利用引擎开发完整的项目为保持合理的设计,需要有面向对象开发的基础。
c) 了解并熟悉Cocos2d-iphone有几大重要的模块。其中物理模块采用Box2D开源项目,因此开发者也需要掌握物理引擎。声音采用的cocosDesion。开发者可以根据实际项目需求,添加需要的模块,避免多余模块的添加,造成不必要的内存浪费。
d) 对于游戏开始,最大的内存消耗来源于图片资源。因此有必要做好图片资源的优化,能用16位图片的就用16位,采用png格式的图片最佳。图片资源可以使用TexturePacker打包成一张图集。输出采用pvr.ccz格式。
http://www.devstore.cn
测试DEMO
本测试只提供官方提供的模板项目,其实在Cocos2d-iphone中还存在一个实例的test.涵盖了所有的Cocos2d-iphone的功能。在工程cocos2d-tests-ios.xcodeproj中。在此只列出cocos2d-iphone新建的demo源码。
HelloWorldScene.h
01
#import “cocos2d.h”#import “cocos2d-ui.h”
02
// -----------------------------------------------------------------------
03
/**
04
- The main scene
05
*/
06
@interface HelloWorldScene : CCScene
07
// -----------------------------------------------------------------------
08
- (HelloWorldScene *)scene;
09
- (id)init;
10
// -----------------------------------------------------------------------
11
@end
HelloWorldScene.m
view sourceprint?
001
#import “HelloWorldScene.h”
002
#import “IntroScene.h”
003
004
// -----------------------------------------------------------------------
005
#pragma mark - HelloWorldScene
006
// -----------------------------------------------------------------------
007
@implementation HelloWorldScene
008
{
009
CCSprite *_sprite;
010
}
011
012
// -----------------------------------------------------------------------
013
#pragma mark - Create & Destroy
014
// -----------------------------------------------------------------------
015
016
- (HelloWorldScene *)scene
017
{
018
return init];
019
}
020
021
// -----------------------------------------------------------------------
022
023
- (id)init
024
{
025
// Apple recommend assigning self with supers return value
026
self = ;
027
if (!self) return(nil);
028
029
// Enable touch handling on scene node
030
self.userInteractionEnabled = YES;
031
032
// Create a colored background (Dark Grey)
033
CCNodeColor *background = ];
034
;
035
036
// Add a sprite
037
_sprite = ;
038
_sprite.position = ccp(self.contentSize.width/2,self.contentSize.height/2);
039
;
040
041
// Animate sprite with action
042
CCActionRotateBy* actionSpin = ;
043
];
044
045
// Create a back button
046
CCButton *backButton = " fontName:@“Verdana-Bold” fontSize:18.0f];
047
backButton.positionType = CCPositionTypeNormalized;
048
backButton.position = ccp(0.85f, 0.95f); // Top Right of screen
049
;
050
;
051
052
// done
053
return self;
054
}
055
// -----------------------------------------------------------------------
056
- (void)dealloc
057
{
058
// clean up code goes here
059
}
060
// -----------------------------------------------------------------------
061
#pragma mark - Enter & Exit
062
// -----------------------------------------------------------------------
063
064
- (void)onEnter
065
{
066
// always call super onEnter first
067
;
068
069
// In pre-v3, touch enable and scheduleUpdate was called here
070
// In v3, touch is enabled by setting userInteractionEnabled for the individual nodes
071
// Per frame update is automatically enabled, if update is overridden
072
073
}
074
075
// -----------------------------------------------------------------------
076
077
- (void)onExit
078
{
079
// always call super onExit last
080
;
081
}
082
083
// -----------------------------------------------------------------------
084
#pragma mark - Touch Handler
085
// -----------------------------------------------------------------------
086
087
-(void) touchBegan:(UITouch *)touch withEvent:(UIEvent *)event {
088
CGPoint touchLoc = ;
089
090
// Log touch location
091
CCLOG(@“Move sprite to @ %@”,NSStringFromCGPoint(touchLoc));
092
093
// Move our sprite to touch location
094
CCActionMoveTo *actionMove = ;
095
;
096
}
097
098
// -----------------------------------------------------------------------
099
#pragma mark - Button Callbacks
100
// -----------------------------------------------------------------------
101
102
- (void)onBackClicked:(id)sender
103
{
104
// back to intro scene with transition
105
replaceScene:
106
withTransition:];
107
}
108
109
// -----------------------------------------------------------------------
110
@end
发了一部分 其他的http://www.devstore.cn/evaluation/testInfo/157-112.html在这个链接 兄弟们可以到这里看