Fork me on GitHub
上一页 1 ··· 64 65 66 67 68 69 70 71 72 ··· 125 下一页

2012年3月9日

摘要: Setup在我们开始实际的应用之前,这有很项目需要设置的步骤,之后我们才能专注于Chipmunk。打开XCode,然后建立一个新的工程,使用‘View-Based’应用程序模板,这会建立一个简单的应用程序,启动应用之后,有个view会被显示出来。我们通用需要导入Chipmunk文件,这个任务将分几步完成,包括创建一个静态的库,并且连接向我们的工程。在这个例子中,我们简单的拷贝我们需要的文件到工程文件夹中。然后下载最新的Chipmunk代码,解压缩,这个文件夹将会包含多个文件,例子以及文档,但是我们只需要关注src文件夹里面的内容。在导入这些文件之前,我建议你创建一个新的group,在other 阅读全文
posted @ 2012-03-09 23:26 pengyingh 阅读(236) 评论(0) 推荐(0)
摘要: 找了些关于loading的资源,贴出来慢慢看。(id) init{ self = [super init]; if ( self ) { // Add the Label (in cocos2D universe) BitmapFontAtlas *label = [BitmapFontAtlas bitmapFontAtlasWithString: @"Initializing Game" fntFile: @"comic_atlas.fnt" alignment: UITextAlig... 阅读全文
posted @ 2012-03-09 23:12 pengyingh 阅读(168) 评论(0) 推荐(0)
摘要: 本来想找一个如何能把HTML的String,解析出来的工具。暂时还没有找到。但是找到一段很不错的code。可以移调里面的标签。- (NSString *)flattenHTML:(NSString *)html { NSScanner *theScanner; NSString *text = nil; theScanner = [NSScanner scannerWithString:html]; while ([theScanner isAtEnd] == NO) { // find start of tag [theScanner sc... 阅读全文
posted @ 2012-03-09 23:06 pengyingh 阅读(181) 评论(0) 推荐(0)
摘要: 本文并不介绍如实去实现a star 算法,也不去介绍什么是a star 算法。如果这方面不太了解了。去文章的末尾两个链接可以先补习一下。本文侧重于在游戏中实际应用。为什么要使用a star 算法:游戏中,我们常常会遇到一些任务或者是怪物的路径移动问题,尤其是有原本的地图的情况下。比如,任务从A走到B,如果直接过去,中间是有条河的,肯定不行。如果绕过去,两侧没有河,一侧是山,一侧是桥,山不能走,挡路,只有桥。 就算任务从桥过去,如何能保证正确的从桥上通过呢?于是我们引入了a star 算法,当然他在游戏中也并不只是这一个应用,只是举例如此引出:我们规定地图,是由一个二维数组组成(当然你说一维也可 阅读全文
posted @ 2012-03-09 23:03 pengyingh 阅读(258) 评论(0) 推荐(0)
摘要: 初始化Chipmunk需要三件事情要去做:初始化它使用一个timer 来让Chipmunk计算模拟器的步骤。创建并且配置Space初始化Chipmunk是很简单的一部分,你只需要调用cpInitChipmunk 函数就行了,把它放在程序初始化的地方。时间的设置,使用一个简单的NSTimer对象,或者一些你想要使用的游戏引擎。也许你要用的Timer就在引擎自身里面。最后,创建一个新的Space,只需要使用cpSpaceNew方法就行了。为了完成这三步,只需要再你的controller文件,引入chipmunk.h头文件就好了。#import "chipmunk.h" 之后,在 阅读全文
posted @ 2012-03-09 23:02 pengyingh 阅读(280) 评论(0) 推荐(0)
摘要: // 画一个圆角矩形CGContextRef contextRef = UIGraphicsGetCurrentContext();CGContextSetRGBStrokeColor(contextRef, 1.0f, 1.0f, 1.0f, 1);CGContextSetLineWidth(contextRef, 20.0f);CGContextAddRect(contextRef, CGRectMake(50.0f, 50.0f, 100.0f, 100.0f));CGContextStrokePath(contextRef);CGLineJoin lineJoin = kCGLineJ 阅读全文
posted @ 2012-03-09 22:55 pengyingh 阅读(474) 评论(0) 推荐(0)
摘要: // 画不规则形状CGContextRef contextRef = UIGraphicsGetCurrentContext();CGContextSetRGBStrokeColor(contextRef, 1.0f, 1.0f, 1.0f, 1); // 填充时用不到CGContextSetLineWidth(contextRef, 2.0f); // 填充时用不到CGFloat components[] = { 1.0f, 0.0f, 0.0f, 1.0f};CGContextSetFillColor(contextRef, components);CGContextMoveToPoint 阅读全文
posted @ 2012-03-09 22:54 pengyingh 阅读(198) 评论(0) 推荐(0)
摘要: // 画矩形和圆形(椭圆也是圆哦) CGContextRef contextRef = UIGraphicsGetCurrentContext();CGContextSetRGBStrokeColor(contextRef, 1.0f, 1.0f, 1.0f, 1);CGContextSetLineWidth(contextRef, 2.0f);CGContextAddRect(contextRef, CGRectMake(50.0f, 50.0f, 200.0f, 100.0f));CGContextAddEllipseInRect(contextRef, CGRectMake(50.0f, 阅读全文
posted @ 2012-03-09 22:52 pengyingh 阅读(404) 评论(0) 推荐(0)
摘要: // 实心圆 实心矩形 CGContextRef contextRef = UIGraphicsGetCurrentContext();CGContextSetRGBStrokeColor(contextRef, 1.0f, 1.0f, 1.0f, 1);CGContextSetLineWidth(contextRef, 2.0f);CGFloat components[] = { 1.0f, 0.0f, 0.0f, 1.0f};CGContextSetFillColor(contextRef, components);CGContextAddRect(contextRef, CGRectMa 阅读全文
posted @ 2012-03-09 22:45 pengyingh 阅读(303) 评论(0) 推荐(0)
摘要: 1,如果视图是从nib中加载的,我们应该首先实现initWithCode:因为nib中的对象实例将存储为归档对象。(某一个view设置为自定义的子view)hitTest代码范例: - (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event{ for (UIView *tmpView in self.subviews ) { if(tmpView.userInteractionEnabled && [tmpView isMemberOfClass:[UIButton class]]) { ... 阅读全文
posted @ 2012-03-09 22:37 pengyingh 阅读(3843) 评论(0) 推荐(0)
上一页 1 ··· 64 65 66 67 68 69 70 71 72 ··· 125 下一页

导航