简体   繁体   English

如何通过SKScene播放视频

[英]How to play video over SKScene

Basically I have an SKScene, and I want to play a video over the scene. 基本上我有一个SKScene,我想在现场播放视频。 The video is confetti falling with an alpha background. 该视频是五彩纸屑,带有alpha背景。 It will play when the player gets a high score. 当玩家获得高分时它将开始播放。 I am using an SKScene with shapes and images drawn with shape nodes and image nodes. 我正在将SKScene与形状和图像一起使用形状节点和图像节点绘制。 I just was wondering if anyone could please tell me how to play the video over the screen and still see the game in the back, and be able to touch the buttons through the video. 我只是想知道是否有人可以告诉我如何在屏幕上播放视频,并且仍然可以看到后面的游戏,并且可以通过视频触摸按钮。 It is supposed to look like an animation playing. 应该看起来像是动画播放。

I am using a video because I was just thinking that playing a video would be more processor efficient than having the game generate particles. 我之所以使用视频,是因为我只是想播放视频比让游戏产生粒子更能提高处理器效率。

There is no built-in iOS solution. 没有内置的iOS解决方案。 You can play 24BPP (fully opaque) movies under iOS, but the only built-in way to display alpha channel video would be to load a series of PNG images with alpha. 您可以在iOS下播放24BPP(完全不透明)电影,但是显示Alpha通道视频的唯一内置方法是加载一系列带有Alpha的PNG图像。 Downside is that takes up a huge amount of memory and it bloats the app download. 缺点是占用大量内存,并且会使应用程序下载膨胀。 If you want to have a look at some working examples of this kind of functionality with a 3rd party app then see Alpha Channel Examples . 如果您想通过第三方应用程序查看此类功能的一些可行示例,请参阅Alpha通道示例 You might also be interested in this blog post which shows example code of how to impl Alpha channel textures in OpenGL would could be implemented on top of SpriteKit too. 您可能还会对此博客帖子感兴趣,该博客文章显示了如何 SpriteKit之上实现如何在OpenGL中实现Alpha通道纹理的示例代码。 The cube example shows rendering an alpha channel movie onto a cube, it was adapted from a Ray Wenderlich tutorial. 多维数据集示例显示了将Alpha通道影片渲染到多维数据集上的方法,该内容是从Ray Wenderlich教程改编而来的。

Here as an answer how to do that with GPUImageView. 这里是一个答案,如何使用GPUImageView做到这一点。 Also project on GitHub here and similar question from stackoverflow 也在这里在GitHub上进行项目以及stackoverflow的类似问题

The video stack doesn't yet support formats with alpha. 视频堆栈尚不支持Alpha格式。 For confetti, you should use SKEmitterNode . 对于五彩纸屑,应使用SKEmitterNode Size it to the area you envisioned for your video, and see Creating Particle Effects , ie, its link to Add a particle emitter to your project and try out the "Snow" effect. 将其调整大小到您为视频所设想的区域,然后参阅“ 创建粒子效果” ,即其链接以向项目中添加粒子发射器并尝试“雪”效果。 It looks more like confetti when you give it a different color than white. 当您给它提供不同于白色的颜色时,它看起来更像纸屑。 Click the dot under "Color Ramp" to set the color. 单击“色带”下的点以设置颜色。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM