问题标签 [skeffectnode]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
0 回答
392 浏览

ios - CIFilter(名称:“CIGaussianBlur”)与 shouldRasterize = true 的 SKEffectNode 性能问题

我正在尝试为游戏中会造成伤害的角色或物体添加光晕。我想为游戏中的“坏”事物(即尖峰、守卫等)发出红光。我正在使用以下代码,但即使将 rasterize 设置为 true,性能也很差。当我添加效果时,性能很快从 60fps 下降到 ~30fps。发光效果需要在不同形状的精灵上,即。圆形、三角形、矩形、人等。我对其他方法持开放态度,尽管下面的代码给了我想要的确切视觉效果。如果我可以让代码执行,我想在“好”对象上发出绿光。

我还通过仅在左侧和右侧添加 1.5 个场景的节点来减少“坏”SKNode 的数量。这种改变似乎没有帮助。问题似乎是当我实际遇到特别大量的 SKNodes 和 SKNodes/SKSpriteNodes 并添加了效果时。

尝试

或者

...

0 投票
3 回答
1613 浏览

swift - SpriteKit - 为整个场景添加模糊

按下暂停按钮时,我试图模糊整个 GameScene。我有一个名为 blurSceen() 的方法,但它似乎没有将效果添加到场景中。有没有办法可以做到这一点,或者我做错了什么?我查看了有关此主题的其他帖子,但无法达到效果。

0 投票
0 回答
483 浏览

ios - SpriteKit: SKSpriteNodes disappear from SKEffectNode after a few seconds

I'm working on a metaballs effect in SpriteKit. I have an SKEffectNode with a shader that compresses the colour range of its buffer. This effectnode has a hundred-odd SKSpriteNode as its children. The effect works great for a couple of seconds, but suddenly, over the course of a few frames, all of the spritenodes vanish from the screen, and the nodecount drops from 100-odd down to 2 (I guess the 2 remaining are the effectnode itself, and the edge chain that forms the container to hold the balls?)

If I add the ball spritenodes directly to the rootnode of the scene, this does not happen. It's only when they are made children of the effectnode that they seem to get aggressively culled after a few seconds.

Interestingly, (and this is visible in the simulator if the frame rate is quite low) the SpriteNodes seem to get culled in the vertical order that they are currently displayed on the screen, from the top of the screen to the bottom.

If the view's showsPhysics property is set to true, I can see the SKSpriteNode's physics bodies are still there onscreen, and rolling around. But their visual representation has vanished, and the view's node count has been depleted. According to the docs showsNodeCount "shows physics bodies that are visible in the scene." So because the nodes are no longer visible, the node count has dropped.

Anyone know what could be causing this, or what tools I could use to debug it?

Standard SpriteKit iOS Swift 2.2 Xcode 7 template, replace the GameScene file with this:

0 投票
2 回答
576 浏览

ios - SKEffectNode 到 SKTexture?

SKEffectionNodes有一个 shouldRasterise “开关”,将它们烘焙成位图,并且在受效果影响的底层节点发生更改之前不会更新它们。

但是我找不到SKTexture从这个光栅化的“图像”创建一个方法。

是否有可能SKTexture从 a 中获得 a SKEffectNode

0 投票
2 回答
6375 浏览

ios - 为 SKSpriteNode 添加发光效果

我在深色屏幕上有一个移动的黑色图像,为了更容易看到我想在图像中添加白光。这是我的动态图像代码:

我不确定如何或使用什么来添加发光,如果您需要更多信息,请询问。

0 投票
0 回答
945 浏览

sprite-kit - 将带有 SKEffectNode 的 CIFilter 应用于 SKSpriteNode

我正在尝试将带有 SKEffectNode 的 CIFilter 应用于 SKSpriteNode。无法使其正常工作,也不知道为什么。我使用模糊来完成这项工作,但无法获得单色照片效果。任何人有任何见解?再次感谢。

0 投票
1 回答
840 浏览

swift - 如何提高 SKEffectNode 性能(Swift)?

所以在我的项目中,我有一个 SKEffectNode,用于在我的一些 spriteNode 周围提供发光效果。我使用 spriteNode (blurNode) 来获取障碍物的颜色,然后将其提供给 effectNode。这工作正常。

我的问题发生在这里。

我想要做的是让障碍物周围的“发光”随着障碍物改变颜色。这正是发生的事情;但是,当我这样做时,我的帧速率下降到 30fps。

所以,我的问题是有人知道如何提高这项任务的性能吗?或者是否有另一种方法可以做到这一点。

我想到的一个想法是在photoshop中手动模糊“neonLine.png”,然后像这样将它添加到模糊节点中 let blurNode = SKSpriteNode(imageNamed: "bluredNeonLine.png")。唯一的问题是我永远无法正确模糊它总是看起来很模糊。

任何帮助将不胜感激。谢谢!

编辑:

这是我项目中发光的一些照片:

iPhone游戏上的发光线

这是发光和改变颜色的线条:

iPhone游戏上的发光线

0 投票
2 回答
429 浏览

swift - SKLabelNode 上的 SKWarpGeometry 作为 SKEffectNode 的子级将标签倒置

我正在尝试将 SKLabelNode 扭曲为 SKEffectNode 的子节点(文档说您可以这样做),但它会在应用扭曲之前将标签节点倒置。这可能是一个错误,但在我提交之前,我想我会在这里问...

这是我的代码:

这段代码应该压扁标签的顶部,然后将其返回到原来的位置(就像你推了一个球或其他东西一样),然而,它把它倒过来,然后压扁顶部(现在是底部单词),然后将其恢复到原来的大小和位置(正面朝上)。

编辑:根据 0x141E 的评论,我将 SKLabelnode 转换为 SKTexture 并添加了一个具有该纹理的新 SKSpriteNode。如果我在 effectNode 上使用 warpNode 函数,它具有将单词倒置然后应用 squish 的相同效果。但是,如果我直接在新的 SKSpriteNode 上使用 warpNode 函数,它就可以正常工作。

新代码如下:

我只是删除了代码的整个 effectNode 部分并添加了新的精灵并对其进行了变形。

0 投票
2 回答
875 浏览

swift - 如何在精灵图像或纹理中切出一个洞以快速使用 spriteKit 显示其背后的内容

我想在 spriteKit 中显示一堆可拖动的图像。有些图像需要我动态地在图形上切一个洞,这样我才能看到图像背后的内容。当我在图像周围拖动时,我将能够通过我在图像中切出的孔看到其他图像。

如果您需要视觉效果,请考虑拼图。

下面的这个堆栈交换链接看起来非常简单和有希望,但是白色的圆圈切口似乎没有显示。至少不在模拟器中。我将不得不看看我是否通过 testflight 在我的 iphone 上获得了更好的结果。

用 SpriteKit 在矩形上画一个洞?

0 投票
1 回答
71 浏览

macos - 查询图形能力以决定是否应用 GPU 密集型效果(通过 SpriteKit)

我有一个用 SpriteKit 编写的游戏,它使用具有模糊效果的 SKEffectNode 来模糊一组精灵,其中一个精灵具有相当大的纹理,并且它们一起覆盖了相当大的屏幕区域。iMac 和 Mac Book Pro 可以很好地解决这个问题,但在更简陋的 Mac Book 上,添加效果节点后帧速率会显着下降。由于效果对游戏的功能并不重要,我可以简单地不要为图形功能不太强大的机器添加 SKEffectNode。

那么问题来了:我可以通过什么 API 来确定“GPU 的能力”或“应用纹理效果时的性能”或 [在此处建议更好的指标] 以及通过什么 API 进行的良好编程检查是什么?感谢您的建议!