使用 Quartz2d 和 Context 插入背景图像?

发布于 2024-09-24 15:39:32 字数 179 浏览 0 评论 0原文

我用 Quartz2d 编写了一个游戏。我想在游戏中插入背景图像。我尝试使用 view.insertSubView 方法执行此操作,但是背景图像始终放置在其他精灵的顶部。即使使用 sendSubviewToBack 也不能解决这个问题。我想我需要以某种方式将背景图像直接绘制到上下文上?

预先感谢您的帮助,

马丁

I have written a game using Quartz2d. I would like a insert a background image to the game. I have tried doing this using the view.insertSubView method however the background image is always placed on top of the other sprites. Even using sendSubviewToBack does not solve this. I assume I need to somehow draw the background image directly onto the context ?

Thanks in advance for any help,

Martin

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

日久见人心 2024-10-01 15:39:32

您可以使用绘制图像

UIImage *myImage = [UIImage imageNamed:@"imageName.png"];
[myImage drawAtPoint:CGPointMake(0, 0)];

但如果它始终相同,您可能应该在 UIView 下方添加一个 UIImageView 来绘制所有游戏^^(但不是像您尝试的那样在视图中,而是在超级视图中)

You can draw an image with

UIImage *myImage = [UIImage imageNamed:@"imageName.png"];
[myImage drawAtPoint:CGPointMake(0, 0)];

But if it's always the same you should maybe add a UIImageView below your UIView which draw all your game ^^ (but not in the View like you tried, but in the superview)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文