gpt4 book ai didi

ios - 使用 CoreGraphics 而不是 SpriteKit 的原因?

转载 作者:可可西里 更新时间:2023-11-01 03:37:42 25 4
gpt4 key购买 nike

SpriteKit 在 GPU 上高效运行。

CoreGraphics 在 CPU 上运行。

我想不出任何 CoreGraphics 可以做而 SpriteKit 做不到的绘图。

鉴于此,您能说出为什么有人可能仍然希望在新应用中更喜欢 CoreGraphics 而不是 SpriteKit 的原因吗?

最佳答案

这不是“非此即彼”的问题,因为他们的能力存在差距。

Core Graphics 可以制作非常复杂的图像,通过具有不同效果和内容的极其复杂的图层构建。但最重要的是,它非常擅长以其他 iOS 框架无法比拟的质量绘制形状和线条。正如苹果所说:

Core Graphics... provides low-level, lightweight 2D rendering with unmatched output fidelity. You use this framework to handle path-based drawing, transformations, color management, offscreen rendering, patterns, gradients and shadings, image data management, image creation, and image masking, as well as PDF document creation, display, and parsing.

https://developer.apple.com/reference/coregraphics

在 SpriteKit 的上下文中,您不会找到 PDF 导出创建、图像创建(纹理创建,是的,但不是图像创建),也不会找到复杂的渐变、颜色管理、复杂的图案、转换和离屏渲染。

同样,你不会在SpriteKit中找到Core Graphics中的那种抗锯齿。

如果你想将你的图像制作作品集成到 UIKit 应用程序中,你最好混合使用 Core Graphics、Core Image 和 Core Animation,而不是尝试使用 SpriteKit 进行此类图像创作和动画制作一个应用程序。

将 SpriteKit 用于可适当受益于将 Sprites 作为主要图形内容的游戏。

例如,您可以为专注于更多动态内容的游戏选择 Core Animation 和 Core Graphics,或者需要比仅从 SpriteKit 获得的更高质量的编程创建内容。或者,您可以使用 Core Graphics 以比从 SKShapeNode 获得的质量更高的质量为 Sprite 制作内容。

所以...类(class)用马。

类(class)基本上是:

A) Sprite 和简单的二维渲染和绘图

B) 各种图形、动态绘图以及对质量和输出类型的更高要求

C) 两者兼而有之

关于ios - 使用 CoreGraphics 而不是 SpriteKit 的原因?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41634525/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com