问题标签 [skspritenode]

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 投票
1 回答
1455 浏览

ios - 如果我稍后使用 SKTextureAtlas,Sprite Kit 是否会多次加载纹理图集?

这让我思考。

-spriteNodeWithImageNamed:游戏开始,我用方法创建精灵。稍后对于动画,我创建了一个 SKTextureAtlas 对象。有人说它更快,因为它-spriteNodeWithImageNamed:会首先在您的应用程序包中查找 png,然后再查看图集。

但我不清楚的是:如果我稍后创建一个 SKTextureAtlas ,这会知道已经加载的图集图像还是会变得愚蠢并再次加载图像?

如果我在多个节点中为同一个图集创建 SKTextureAtlas 对象。它会多次加载图集吗?我必须确保我对任何图集只使用一个 SKTextureAtlas 实例吗?

0 投票
1 回答
207 浏览

xcode - 是否可以告诉 Xcode 不要在生成的纹理图集中旋转纹理?

我在 70 帧的长舞蹈动画中遇到了非常糟糕的表现。Sprite Kit 经常卡顿,并且 SKSpriteNode 的尺寸很小。

在地图集中,我看到我的许多框架都旋转了 90 度。我得到的印象是 Sprite Kit 每次碰到一个旋转的帧时都会结结巴巴。

是否有一个构建设置会告诉 Xcode 不允许旋转?

0 投票
1 回答
129 浏览

ios - 如何获得精灵相对于世界坐标的 zRotation?

例如,如果你有一个旋转的精灵,你添加另一个旋转的精灵,等等。您将如何确定子精灵的屏幕 zRotation 或精灵的“绝对”旋转?

0 投票
1 回答
512 浏览

objective-c - 子类化方法返回实例类型

我有一个自定义类,它是SKSpriteNode. 我正在尝试覆盖spriteNodeWithColor:size:返回的方法instancetype。我试试这个:

它每次都崩溃。在此先感谢您的帮助

0 投票
3 回答
1281 浏览

sprite-kit - 如何将精灵套件元素放置在常规 UIKit 元素之上

我试图让用户能够将 skspritenode 拖动到 UIImageView 和 UIButton 上,但是每当我创建场景时,它就会出现在 UI 元素的后面。我该如何解决?

0 投票
1 回答
710 浏览

ios7 - 如何在 iOS7 SpriteKit 中为不同大小的图像设置动画?

我正在使用流动代码为我的精灵节点设置动画。

动画效果很好,只是一张图像看起来更大且模糊。我有 4 张图片,其大小如下:

最后一个的大小与其他三个不同。动画运行时,最后一张图片会放大。精灵的最后一帧看起来会比其他帧大。你能告诉我如何解决这个问题吗?

非常感谢。

杰克

0 投票
1 回答
1453 浏览

ios - iOS - bodyWithPolygonFromPath : Body is the same as the path but collisions are not working properly

First i'd like to say thanks to every users on this website because i'm always finding solutions here and it's sooo helpful !

I'm trying to make a game like Xonix, Bix or Jezzball with SpriteKit. Anyway, i have a ball bouncing against walls, and i'm trying to make obstacles where it can't go, those obstacles are made from CGPathref (the user makes it with its movements)

I'm using bodyWithPolygonFromPath to create the physicsbody of the skspritenode, it's working, but not always. I've downloaded YMCPhysicsDebugger to see the content of the body, and in every case, it's good, but i've seen that when i have more than 4 points on the CGPath, the ball does not collide against the whole of the body, it only collides against a smaller zone.. I've tried and searched a lot without any results.. I've tried to make the points of CGPath counterclockwise, it doesn't work as well, even in the other side..

I'm copying you the code for the creation of SKSpriteNode, but i doubt it will be useful, i think the problem is with my points, maybe i need more explanations on how the physicsbody works with a polygon

Here are two pictures of my "game", the first one works, the ball bounces right back against it. The second one is not working like it should, only the upper part is detected for collision.

http://hpics.li/86a69e2

http://hpics.li/e16d18e

I've also tried to detect when the ball enters an obstacle in the update function to manually make it bounce against it, but of course, it's not really working. Plus my math studies are not that good lol

I've also thought about making several SKSpriteNode everytime a CGPath has more than 4 points, but i don't really know how to do that in mathematics..

Anyway, that's a long post, I hope some of you will read it all and understand it all (sorry for my english, i'm french!) and most of all, will be able to help me !!

Thank you very much

0 投票
2 回答
288 浏览

sprite-kit - 如何使 SKSpriteNode 仅对某些碰撞做出反应

在这个项目中,有两个玩家,都可以射击。当对面玩家的子弹击中一艘船时,它会降低他们的健康并消失,这很好用。问题是我不希望船只或子弹对相互碰撞做出反应。

这是制作第一个播放器的代码:

第二个玩家:

类别的初始化:

玩家一的子弹制作:

玩家二的子弹制作:

这样做的方式是否有任何明显的问题会导致第一个玩家和子弹对碰撞做出反应?在此先感谢您的帮助,并为长期阅读感到抱歉。

0 投票
1 回答
1577 浏览

ios - physicsBody 与 spriteNode 未对齐

我正在创建一个 spritenode,设置它的位置并将其锚点更改为 (0, .5),然后创建一个 phyicsbody。

物理体愚蠢地认为我的锚点仍在 (.5, .5) 处。

此处引用了相同的问题,但未解决:Physicsbody 不坚持节点的锚点

我做事的顺序是正确的,只是我的物理身体很固执。

0 投票
3 回答
568 浏览

sprite-kit - 引用 Sprite Kit 中另一个类的场景

好的,我一直在尝试解决这个问题并搜索网络和论坛,但我还没有运气。

我想做的是以下。我有一个 MainMenuScene,它是一个 SKScene。由于我在该场景中添加了许多 SKAction 和其他内容,因此我希望能够将其分解为不同的文件。因此,例如,当玩家按下“设置”按钮时,我会使用不同的文件来编写会发生的事情,而不是使用 MainMenuScene 并使其更大。

所以我的问题是:我希望能够从我的 SettingsSubScene.m 文件中引用 MainMenuScene.m 中的 SKScene。SettingsSubScene.m 如下:

我使用以下代码从 MainMenuScene.m 调用它:

我得到一个 exc_bad_access 错误。当然我做错了,我敢打赌有一种方法可以做到这一点,而不是创建一个大的 MainMenuScene 文件,但我还没有找到它。有人可以帮忙吗?

谢谢