问题标签 [skshapenode]

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 回答
1016 浏览

ios7 - iOS 7 iPad SpriteKit - 使用不规则的 SKShapeNode 作为 SKCropNode 的掩码

有谁知道如何使用不规则形状节点使用 iOS 的 spritekit 裁剪图像?问题是当我对其进行 skcrop 时,形状有 2 层,因此裁剪失败。要裁剪一个必须使用单层。知道如何在加载场景之前先栅格化形状吗?我已经尝试过 skeffectnode 和 shouldRasterize ,但这也失败了,很可能是因为它也包含 2 个孩子,或者在加载场景后发生光栅化。我也尝试将形状转换为纹理,但由于与 skeffectnode 相同的原因而失败。我已经查看了有关堆栈溢出的其他可能解决方案,但似乎没有一个有效或仅限于正方形,所以我认为这是一个只能存在于 iOS7 中的错误,所以请不要

现在所有迹象都表明不使用带有填充的 skshapenode 来裁剪图像。

0 投票
0 回答
131 浏览

ios - Sprite Kit - Sprite 和 Edge 碰撞时有很大的间隙 [见截图]

正如您在下面的屏幕截图中看到的,圆(SKShapeNode)和线(也是 SKShapeNode)之间有很大的差距。

自然,这两个项目在碰撞时都应该接触。

这是我的代码:

以及 SKShapeNode 的 +node 方法:

有谁知道我哪里出错了?

谢谢

在此处输入图像描述

0 投票
2 回答
907 浏览

coordinates - SpriteKit - How do I check if a certain set of coordinates are inside an SKShapeNode?

In my game, I'm trying to determine what points to dole out depending on where an arrow hits a target. I've got the physics and collisions worked out and I've decided to draw several nested circular SKShapeNodes to represent the different rings of the target.

I'm just having issues working out the logic involved in checking if the contact point coordinates are in one of the circle nodes...

Is it even possible?

0 投票
0 回答
164 浏览

sprite-kit - 如何将圆(与 SKShapeNode 的 SKAction)同步到球(由 SKShapeNode)?

我尝试将圆(用SKActionby创建SKShapeNode)与球(用 by 创建)同步SKShapeNode。这是这段代码。但它不能很好地工作。我应该怎么办?

预先感谢您的帮助。

0 投票
0 回答
811 浏览

ios - SKShapeNode 填充颜色的动画变化?

以下是我遇到问题的代码:

我正在尝试以动画方式更改 backgroundRect 的填充颜色,但似乎从未调用过 SKAction 的 actionBlock。我得到的唯一输出是“什么”,所以我不明白第一个 NSLog 是如何不被调用的。任何帮助将不胜感激。

0 投票
1 回答
551 浏览

sprite-kit - SKShapeNode ellipseInRect,精灵没有出现在场景中

我正在尝试在场景中心创建一个椭圆:

这被添加到了didMoveToView,视图上的节点数显示为1,但我没有看到路径。如何使用SKShapeNode ellipseInRectAPI 将椭圆添加到我的场景中?

0 投票
1 回答
1999 浏览

sprite-kit - SpriteKit 将 SKShapeNode 放置在场景中心

我有一个要在场景中心绘制的椭圆

但它出现在场景中,如下所示:

密景

我如何将它定位在场景的中心?

0 投票
1 回答
2387 浏览

swift - Detecting Touch on SKShapeNode that is a Line

I have an SKShapeNode that I have created and given a CGPath to. This is in my GameScene.swift in didMoveToView:

And this is how I'm detecting touches, again in the Scene:

The line node is showing up with no issues. However, it is not registering touchesEnded at all.

Really, I have three questions nebulous to this:

  1. Is there a better way to create an SKShapeNode that is a line between two points without calling a convenience initializer? I plan on subclassing SKShapeNode to add additional logic to the node, and the subclass doesn't have access to convenience initializers of the superclass.

  2. More importantly, how do I get the scene to recognize my line node there and trigger touchesEnded?

  3. Is there a way, using that mechanism, I can make it a bit more "fuzzy", so it handles touches close to the line, instead of on the line? My eventual plan is to make it thinner, but I'd still like to have a large touch zone. I figure if nothing else, I can create two nodes: one clear/thick and the other red/thin, and handle touch events on the clear one, but I would like to know if there's a better way.

0 投票
3 回答
5203 浏览

sprite-kit - Sprite Kit 中的 SKShapeNode 性能不佳

我正在Sprite Kit 中制作“ Achtung die kurve ”克隆。对于不断移动的线/玩家,我使用 CGMutablePathRef 和 SKShapeNode。在更新方法中,我正在这样做

添加到该行。update 方法也是不断更新 _xPos 和 _yPos 以使其增长。

我想我真正要问的是是否有另一种更有效的画线方式,因为我现在这样做的方式会在一段时间后(大约 15-20 秒)大幅降低帧速率。此时 FPS 会不断下降,直到游戏无法玩。Time Profiler 告诉我这一行:_lineNode.path = path 是导致 FPS 下降的原因。

谢谢你的帮助!非常感谢。

PS。我试图根本不使用 SKShapeNode,因为它们似乎无法很好地绘制线条(曲线中的小孔/伪影等)

截屏: 不断绘制的线条

0 投票
1 回答
752 浏览

ios - 检测圆形 SKShapeNode 中的触摸?

我需要检测圆形的触摸,问题是虽然形状看起来像圆形,但可触摸区域仍然是矩形。仅当用户触摸我的圈子时,我如何检测触摸?

这就是我现在正在做的事情: