小编giz*_*tai的帖子

如何在GLPaint示例代码中创建自己的recordedPath

我最近下载了GLPaint示例代码并查看了其中一个非常有趣的部分.有一个recordsPaths NSMutableArray,其中包含点,然后由GLPaint读取和绘制.

它在这里宣布:

NSMutableArray *recordedPaths;
recordedPaths = [NSMutableArray arrayWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Recording" ofType:@"data"]];
if([recordedPaths count])
     [self performSelector:@selector(playback:) withObject:recordedPaths afterDelay:0.2];
Run Code Online (Sandbox Code Playgroud)

这是播放代码:

 - (void) playback:(NSMutableArray*)recordedPaths {

     NSData*                    data = [recordedPaths objectAtIndex:0];

     CGPoint*               point = (CGPoint*)[data bytes];

     NSUInteger               count = [data length] / sizeof(CGPoint),

                              i;



     //Render the current path

     for(i = 0; i < count - 1; ++i, ++point)

          [self renderLineFromPoint:*point toPoint:*(point + 1)];



     //Render the next path after a short delay 

     [recordedPaths removeObjectAtIndex:0];

     if([recordedPaths count])

          [self performSelector:@selector(playback:) withObject:recordedPaths afterDelay:0.01];

}
Run Code Online (Sandbox Code Playgroud)

据我所知,recordedPaths是一个可变数组,他在其中构造CGPoint数组,然后读取和呈现.我想放入我自己的阵列,我一直遇到麻烦.

我尝试将recordedPaths声明更改为:

      NSMutableArray …
Run Code Online (Sandbox Code Playgroud)

iphone objective-c quartz-2d

4
推荐指数
1
解决办法
1860
查看次数

标签 统计

iphone ×1

objective-c ×1

quartz-2d ×1