1

我正在使用一个 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 开发游戏的方法或示例。

提前致谢!

4

1 回答 1

4

使用一个框架,cocos2d 是 iphone 上用于 2d 游戏的最好和最常用的框架之一。还有 Unity 和其他一些 3d 框架,如果您使用 UIView 和 CGContextRef 我猜您正在制作 2d 游戏。

http://www.cocos2d-iphone.org

这个框架使用 OpenGLES 来渲染精灵,它带有 2 个不同的物理引擎可供使用(我更喜欢 box2d),并且有一个非常繁忙和有用的社区可以从中获得帮助。

祝你好运!

于 2010-12-07T17:04:20.547 回答