如何在SKScene上播放视频

时间:2015-10-25 05:23:58

标签: ios swift sprite-kit skscene

基本上我有一个SKScene,我想在场景中播放视频。视频是五彩纸屑落在alpha背景下。它将在玩家获得高分时播放。我正在使用SKScene,其形状和图像使用形状节点和图像节点绘制。我只是想知道是否有人可以告诉我如何在屏幕上播放视频并仍然看到后面的游戏,并能够通过视频触摸按钮。它看起来像是一个动画片。

我正在使用视频,因为我只是认为播放视频比使用游戏生成粒子更有效。

3 个答案:

答案 0 :(得分:1)

没有内置的iOS解决方案。您可以在iOS下播放24BPP(完全不透明)电影,但显示Alpha通道视频的唯一内置方式是加载一系列带alpha的PNG图像。缺点是占用了大量的内存,它使应用程序下载变得臃肿。如果您想查看第三方应用程序的此类功能的一些实际示例,请参阅Alpha Channel Examples。您可能也对此博文感兴趣,该博文显示了如何在SpriteKit上实现impl Alpha channel textures in OpenGL的示例代码。立方体示例显示将Alpha通道影片渲染到多维数据集上,它是根据Ray Wenderlich教程改编的。

答案 1 :(得分:0)

Here作为答案,如何使用GPUImageView做到这一点。还要在GitHub here上进行项目开发,并在stackoverflow上进行类似的问题

答案 2 :(得分:0)

视频堆栈尚不支持Alpha格式。对于五彩纸屑,应使用def playGameL1(): drawTime = random.randint(3,7) print("You and the outlaw have lined up back to back and begin") print("taking 10 paces away from eachother...") time.sleep(5) print("The bystander who is conducting the quickdraw battle yells:") print("'Ready!'") time.sleep(drawTime) print("'DRAW!'") start = datetime.datetime.now() draw = input() end = datetime.datetime.now() reactionTime = (end-start) print ("Your reaction time was: ", reactionTime) if reactionTime<3: print("BANG!") time.sleep(1) print("You drew first and won the draw!") time.sleep(2) print("The next outlaw approaches...") playGameL2() else: print("BANG!") time.sleep(1) print("The outlaw drew first and you lost!") time.sleep(2) gameLoss() 。将其调整大小到您为视频设想的区域,然后查看Creating Particle Effects,即指向Add a particle emitter to your project的链接,然后尝试“雪”效果。当您给它提供不同于白色的颜色时,它看起来更像纸屑。单击“色带”下的点以设置颜色。