摘要: 世界:创建世界对象作为一切对象的父对象; b2Vec2 gravity; gravity.Set(0.0f, -10.0f); //重力大小; bool doSleep = false; //静止位置不在进行物理模拟; world = new b2World(gravity, doSleep); world->SetContinuousPhysics(true);tick函数中;进行物理模拟: int32 velocityIterations = 8; //速度迭代次数; int32 positionIterations = 1; //位置迭代次数; wo... 阅读全文
posted @ 2012-05-13 16:48 moon_7 阅读(482) 评论(0) 推荐(0) 编辑
摘要: //预加载背景音乐 和 预加载音效 在播放背景音乐与音效之前都要提前加载,为了防止加载消耗时间发生与游戏不同步; [[SimpleAudioEngine sharedEngine] preloadBackgroundMusic:@"office_background.mp3"]; [[SimpleAudioEngine sharedEngine] preloadEffect:@"office_background.mp3"]; //播放背景音乐 和 循环播放背景音乐; [[SimpleAudioEngi... 阅读全文
posted @ 2012-04-23 21:56 moon_7 阅读(4317) 评论(0) 推荐(0) 编辑
摘要: 利用Texture Packer进行打包纹理贴图集时,add Folder时,没必要把全部的文件都放在同一个文件夹中;可以按照自己的方式把这些图片放在不同的子目录下(比如sprites\animals,sprites\monsters),之后当你从cocos2d中引用它们的时候只需指定相对路径即可。例如:add Folder添加的文件夹下还有一个文件夹firstlevel文件;打包后的plist文件; CCSpriteFrameCache* sp=[CCSpriteFrameCache sharedSpriteFrameCache]; [sp addSpriteF... 阅读全文
posted @ 2012-04-20 22:19 moon_7 阅读(1084) 评论(0) 推荐(0) 编辑
摘要: HelloWorldLayer.m:中(相当于游戏界面)-(void)printString{ CCLOG(@"游戏进行中。。。");}-(id) init{ if( (self=[super init])) { CCSprite* sprite=[CCSprite spriteWithFile:@"Icon.png"]; sprite.position=ccp(150, 150); CCRotateBy* by=[CCRotateBy actionWithDuration:1 angle:60.0]; //不停旋转的spr... 阅读全文
posted @ 2012-04-20 00:26 moon_7 阅读(1314) 评论(0) 推荐(0) 编辑
摘要: CCLayer是不接收触屏事件的,需要我们手动开启触摸事件; self.isTouchEnabled=YES;针对触屏事件,有两个协议;[CCStandardTouchDelegate 和CCTargetedTouchDelegate]CCLayer默认实现CCStandardTouchDelegate协议;CCStandardTouchDelegate协议包含如下方法:-(void)ccTouchesBegan:(NSSet *)touches withEvent:(UIEvent *)event;-(void)ccTouchesMoved:(NSSet *)touches w... 阅读全文
posted @ 2012-03-25 01:01 moon_7 阅读(689) 评论(0) 推荐(0) 编辑
摘要: 默认模拟器的分辨率为480*320;但是现在主流的iphone和touch等设备分辨率都为960*640,按模拟器分辨率设置好的图片位置在真机上就会错位;怎样把模拟器分辨率调整为960*480呢?1.打开模拟器-状态栏中的硬件-设备-iphone(Retina)2.打开AppDeledate.m-找到if( ! [director enableRetinaDisplay:YES] )把注释去掉;[支持高清]为此还需要准备 480*320 和 960*480 两种格式的图片480*320的命名为“xx.png” 960*640的命名为“xx-hd.png”现在就可以在模拟器上进行虚拟的真机调试了 阅读全文
posted @ 2012-03-19 23:40 moon_7 阅读(406) 评论(0) 推荐(0) 编辑
摘要: 转自:http://www.himigame.com/iphone-cocos2d/482.html 感谢HIMI分享; //加载背景音乐&&游戏中的音效 [[SimpleAudioEngine sharedEngine] preloadBackgroundMusic:@"powerup.caf"]; [[SimpleAudioEngine sharedEngine] preloadEffect:@"shake.caf"]; //播放背景音乐 [[SimpleAudioEngine sharedEngine] playBackgrou.. 阅读全文
posted @ 2012-03-19 22:15 moon_7 阅读(279) 评论(0) 推荐(0) 编辑
摘要: CCSprite* watch=[CCSprite spriteWithFile:@"office_watch.png"]; [self addChild:watch]; //表的背景; watch.position=ccp(250, 160); spoint=[CCSprite spriteWithFile:@"office_point.png"]; spoint.position=ccp(250,160); //表的背景2 [self addChild:spoint]; // 进度条 ... 阅读全文
posted @ 2012-03-18 22:14 moon_7 阅读(2510) 评论(0) 推荐(0) 编辑
摘要: //To绝对 By相对; CCSprite* sprite=[CCSprite spriteWithFile:@"add1.png"]; sprite.position=ccp(70, 50); [self addChild:sprite]; 移动: CCMoveTo* moveTo=[CCMoveTo actionWithDuration:2 position:ccp(200, 300)]; //直线移动到ccp(200,300) CCMoveBy* moveBy=[CCMov... 阅读全文
posted @ 2012-03-18 19:20 moon_7 阅读(630) 评论(0) 推荐(0) 编辑
摘要: 转自:http://www.himigame.com/iphone-cocos2d/423.html 感谢HIMI分享。。。。//部落格------//CCTransitionTurnOffTiles *transitionScene = [CCTransitionTurnOffTiles transitionWithDuration:3 scene:scenec];//近远-远近-----//CCTransitionShrinkGrow *transitionScene = [CCTransitionShrinkGrow transitionWithDuration:3 scene:scen 阅读全文
posted @ 2012-03-18 10:26 moon_7 阅读(314) 评论(0) 推荐(0) 编辑