Fork me on GitHub

2012年4月6日

摘要: http://blog.csdn.net/davintanger/article/details/6836143Cocos2d 开发中提供了两种touch处理方式,Standard Touch Delegate和 Targeted Touch Delegate方式(参见CCTouchDelegateProtocol.h中源代码),CCLayer默认是采用第一种方式(参见CCLayer的 registerWithTouchDispatcher方法)。在CCLayer子类中要能接收touch事件,首先需要激活touch支持,在init方法中设置isTouchEnabled值为YES。Standar 阅读全文
posted @ 2012-04-06 19:33 pengyingh 阅读(1081) 评论(0) 推荐(0)
摘要: 参考http://www.raywenderlich.com/1271/how-to-use-animations-and-sprite-sheets-in-cocos2d用到zwoptex工具。plist输出的时候,选择cocos2d格式。流程简介:先用plist创建一个spriteFrameCache然后创建一个spriteBatchNode然后创建一个队列存放Cache的图片然后创建一个CCAnimation对象播放这个队列然后创建一个action来播放动画。overif( (self=[super init])) {[[CCSpriteFrameCache sharedSpriteFr 阅读全文
posted @ 2012-04-06 19:27 pengyingh 阅读(562) 评论(0) 推荐(0)
摘要: CCParticleSystem *sun;//// fire // CCParticleSystem* ff = [CCParticleFire node];// ff.position = ccp(80,90); // ff.totalParticles = 50;// ff.life = 2.0f;// ff.texture = [[CCTextureCache sharedTextureCache] addImage: @"fire.png"];// [self addChild:ff... 阅读全文
posted @ 2012-04-06 18:19 pengyingh 阅读(381) 评论(0) 推荐(0)
摘要: 一:operations(任务)cocoa提供了三种不同的operations1:Block operations(NSBlockOperation)Thesefacilitate the execution ofone or more block objects.C代码#import<UIKit/UIKit.h>@inter<span>f</span>aceOperationsAppDelegate:NSObject<UIApplicationDelegate>{UIWindow*window;NSBlockOperation*simpleOp 阅读全文
posted @ 2012-04-06 18:00 pengyingh 阅读(3972) 评论(0) 推荐(0)
摘要: http://o0o0o0o.iteye.com/blog/8055811:CCSpriteBatchNodeCCSpriteBatchNode* batch = [CCSpriteBatchNode batchNodeWithFile:@"bullet.png"]; CCArray* bullets = [batch children];2:用多个单独的文件创建动画CCAnimation, CCSpriteFrame+(CCAnimation*) animationWithFile:(NSString*)name frameCount:(int)frameCount de 阅读全文
posted @ 2012-04-06 17:59 pengyingh 阅读(2866) 评论(0) 推荐(0)
摘要: 转载地址:http://blog.csdn.net/ssihc0/article/details/6784819 CCSpriteFrameCache *cache = [CCSpriteFrameCache sharedSpriteFrameCache]; [cache addSpriteFramesWithFile:@"t1.plist" textureFile:@"t1.png"]; CCSprite *mySprite = [CCSprite spriteWithSpriteFrameName:@"a1.png"]; mySp 阅读全文
posted @ 2012-04-06 17:46 pengyingh 阅读(863) 评论(0) 推荐(0)
摘要: 一般游戏图片资源会打包成一张大图,这样节省空间,又提升速度。打包工具有Zwoptex和texturepacker等等。 CCSpriteBatchNode的初始化只要一张图片,也就是那张大图。然后把所有用到那张大图里面的小图的sprite都加到 CCSpriteBatchNode的child,绘制效率就会提高。1) 缓冲sprite帧和纹理 // 从纹理贴图集中预加载精灵帧,这个方法做了以下几件事:寻找工程目录下面和输入的参数名字一样,但是后缀是.png的图片文件。然后把这个文件加入到共享的CCTextureCache中。解析plist文件,追踪所有的sprite在spritesheet... 阅读全文
posted @ 2012-04-06 16:56 pengyingh 阅读(6092) 评论(0) 推荐(0)
摘要: http://blog.sina.com.cn/s/blog_8c7c56230100utax.htmlcocos2d中层颜色的改变,在0.9版本中使用如下的方法:在.h文件中如下声明接口HelloworldLayer : CCColorLayer{}在.m文件中的init中做如下修改if( (self=[super initWithColor:ccc4(255,255,255,255)] )){}但是在1.0以上版本中却将CCColorLayer改成CCLayerColor,其他的使用方法一样在.h文件中声明接口如下HelloworldLayer :CCLayerColor{}在.m文件中的 阅读全文
posted @ 2012-04-06 15:17 pengyingh 阅读(733) 评论(0) 推荐(0)
摘要: 在cocos2d 1.0一下,会有CCSpriteSheet提示,但是在1.0以上的版本中,CCSpriteSheet已经被替换成CCSpriteBatchNode,其相应的方法也被替换,如:CCSpriteSheet*mgr = [CCSpriteSheetspriteSheetWithFile:@"flight.png"capacity:5];已被替换成:CCSpriteBatchNode*mgr = [CCSpriteBatchNodebatchNodeWithFile:@"flight.png"capacity:5]; 阅读全文
posted @ 2012-04-06 14:49 pengyingh 阅读(810) 评论(0) 推荐(0)
摘要: Labels and Fonts 标签和字体Introduction 介绍cocos2d 支持 TTF (True Type Fonts) 标签和纹理 atlas 标签.Pros and Cons of TTF labels: (Label)+ All the pros of TTF fonts: any size, kerning support, etc.+ 简单实用,不需要外部编辑器.- 创建和更新很慢,因为一个新的纹理将要被创建Pros and Cons of texture atlas labels: (LabelAtlas,BitmapFontAtlas)+ 创建和更新很快,因为它 阅读全文
posted @ 2012-04-06 14:40 pengyingh 阅读(2807) 评论(0) 推荐(0)
摘要: Labels and Fonts 标签和字体Introduction 介绍cocos2d 支持 TTF (True Type Fonts) 标签和纹理 atlas 标签.Pros and Cons of TTF labels: (Label)+ All the pros of TTF fonts: any size, kerning support, etc.+ 简单实用,不需要外部编辑器.- 创建和更新很慢,因为一个新的纹理将要被创建Pros and Cons of texture atlas labels: (LabelAtlas,BitmapFontAtlas)+ 创建和更新很快,因为它 阅读全文
posted @ 2012-04-06 13:59 pengyingh 阅读(1182) 评论(0) 推荐(0)
摘要: 原文地址:关于CCBitmapFontAtlas错误问题作者:七贤林子在cocos2d 0.9版本中,存在CCBitmapFontAtlas类,但是在1.0及以上版本中却找不到这个类了,通过xcode创建的cocos2d工程后,如果你按照0.9版本的方式使用CCBitmapFontAtlas,将会报错,因为在1.0及以上版本中已经将CCBitmapFontAtlas替换成了CCLabelBMFont,其使用方法如下:CCLabelBMFont*label = [CCLabelBMFontlabelWithString:@"Go back"fntFile:@"fon 阅读全文
posted @ 2012-04-06 13:33 pengyingh 阅读(570) 评论(0) 推荐(0)
摘要: 原文地址:cocos2d中CCAnimation的使用(cocos2d1.0以上版本)作者:七贤林子在cocos2d 0.9及以下版本中,CCAnimation中可以使用animationWithName,但在1.0及以上版本中,此方法已经不能使用了,而是使用animationWithFrames替代,CCAnimation animation = CCAnimation.animationWithFrames(list); [[CCSpriteFrameCache sharedSpriteFrameCache]addSpriteFramesWithFile:@"animations 阅读全文
posted @ 2012-04-06 10:23 pengyingh 阅读(5957) 评论(0) 推荐(0)
摘要: 问:为什么每当UIScrollView滑动的时候,cocos2d的所有动画都会停止?因为尝试了些coco2d写的scrollview感觉效果都不太理想,所以打算用UIScrollView来实现一些功能的,可是遇到这样一个棘手的问题,感觉整个cocos2d都停止了一样,连显示的FPS也停了,只要scrollview一停止滑动,所有的动画效果都立刻恢复了怎么解决这个问题?答:首先:在CCDirectorIOS.m 文件中 第640行 找到以下注释.// If you want to attach the opengl view into UIScrollView// uncomment this 阅读全文
posted @ 2012-04-06 09:26 pengyingh 阅读(3345) 评论(0) 推荐(0)

导航