我正在使用一个 UIView 和 GraphicsContext 开发 iPhone 游戏应用程序。以下是我正在做的事情:
UIGraphicsBeginImageContext(CGSizeMake(320, 480));
CGContextRef contextRef = UIGraphicsGetCurrentContext();
使用 contextRef 绘图:
UIImage* imageContext = UIGraphicsGetImageFromCurrentImageContext();
... call [self setNeedsDisplayInRect];
(void)drawRect:(CGRect)rect {
[imageContext drawAtPoint:CGPointMake(0, 0)];
// it takes a lot time (about 0.120 seconds) to draw imageContext on iPhone 4 device....
}
问题是绘制 imageContext 需要很多时间。大约需要 0.12 秒或更长时间。在 iPhone 设备上,绘制图像需要很长时间。因此,我正在寻找一种解决方案来解决问题或在更短的时间内绘制图像。
有谁知道如何减少时间?如何在 iPhone 上开发游戏?在 App Store 中,有很多游戏。每场比赛都有适当的速度。
请向我推荐使用一个 UIView 开发游戏的方法或示例。
提前致谢!