skshapenode

Swift SKShapeNode shapeWithSplinePoints

。_饼干妹妹 提交于 2019-12-01 12:29:56
问题 I am trying create a CGPath for a node to follow but when I have tried using SKShapeNode as defined in the actions and constants slide from 608_hd_best_practices_for_building_spritekit_games I get the error Extra argument 'count' in call . Any thoughts? import SpriteKit class GameScene: SKScene { var groundNode: SKSpriteNode? = SKSpriteNode() var path = [CGPoint]() override func didMoveToView(view: SKView) { groundNode = childNodeWithName("ground") as? SKSpriteNode } override func

Creating a subclass of SKShapeNode

白昼怎懂夜的黑 提交于 2019-12-01 09:06:17
问题 class ColorRectangle: SKShapeNode { var width: CGFloat! var height: CGFloat! var rectColor: UIColor! convenience init(rectOfSize: CGSize, colorOfRectangle rectColor: UIColor) { super.init(rectOfSize: rectOfSize) self.width = rectOfSize.width self.height = rectOfSize.height self.rectColor = rectColor self.fillColor = rectColor self.strokeColor = rectColor } } Can't get the initializer right. What do I do? 回答1: Try changing your initializer like this: class ColorRectangle: SKShapeNode { var

how to create a circle with rounded ends for each quadrant

守給你的承諾、 提交于 2019-12-01 05:11:12
I have created a circle that is divided into quadrants. I am trying to make the ends of each quadrant rounded with a given gap between each quadrant, but I get some strange behavior. I guess I'm missing something. Below is an image of what I'm getting and the relevant code. I want the ends to be similar to that of the Apple Watch activity ring. class GameScene: SKScene { let radius = CGFloat(100) var topRightPathNode : SKShapeNode! var bottomRightPathNode : SKShapeNode! var bottomLeftPathNode : SKShapeNode! var topLeftPathNode : SKShapeNode! override func didMove(to view: SKView) { } override

how to create a circle with rounded ends for each quadrant

让人想犯罪 __ 提交于 2019-12-01 02:10:49
问题 I have created a circle that is divided into quadrants. I am trying to make the ends of each quadrant rounded with a given gap between each quadrant, but I get some strange behavior. I guess I'm missing something. Below is an image of what I'm getting and the relevant code. I want the ends to be similar to that of the Apple Watch activity ring. class GameScene: SKScene { let radius = CGFloat(100) var topRightPathNode : SKShapeNode! var bottomRightPathNode : SKShapeNode! var bottomLeftPathNode

Why SKShapeNode does not have anchor point? [closed]

与世无争的帅哥 提交于 2019-11-30 22:28:28
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 5 years ago . i am trying to understand why SKShapeNode does not have an anchor point ? 回答1: When you use an image you may need to align it on its node's position. There's no other way to do so but through anchorPoint because the image itself can't be modified (not easily anyway). When you create a shape you have full control

How to cut random holes in SKSpriteNodes

本小妞迷上赌 提交于 2019-11-30 17:33:39
Aside from the fact that the question asked here : Draw a hole in a rectangle with SpriteKit? has not satisfactorily been answered in its own right, the most significant difference between the two is that this question requires an absence of workarounds and specifically asks about reversing the functionality of SKCropNodes. The primary concerns in this question cannot be addressed by the type of hacky ways the above question could be answered due to the randomness of the holes, the number of holes, and the variation in objects to which the holes are to be applied. Hence the Swiss Cheese

Swift: detecting intersection from sprite kit SKShapeNode drawings

梦想与她 提交于 2019-11-30 15:30:51
I'm drawing with Sprite Kit. I would like to detect when user's drawings are intersecting. I tried to following code but it doesn't work. It seems sprite kit is not saving all the points: override func touchesMoved(touches: NSSet, withEvent event: UIEvent) { /* Called when a touch begins */ touch = touches.anyObject() as UITouch! for drawingPoint in drawingPoints{ if(touch.locationInNode(self) == drawingPoint){println(true)} } drawingPoints.append(touch.locationInNode(self)) } Here is a function for segments intersection in swift. func linesIntersect(line1 : CGPointInterval, line2 :

How to cut random holes in SKSpriteNodes

穿精又带淫゛_ 提交于 2019-11-30 01:15:05
问题 Aside from the fact that the question asked here : Draw a hole in a rectangle with SpriteKit? has not satisfactorily been answered in its own right, the most significant difference between the two is that this question requires an absence of workarounds and specifically asks about reversing the functionality of SKCropNodes. The primary concerns in this question cannot be addressed by the type of hacky ways the above question could be answered due to the randomness of the holes, the number of

Swift: detecting intersection from sprite kit SKShapeNode drawings

 ̄綄美尐妖づ 提交于 2019-11-29 22:14:46
问题 I'm drawing with Sprite Kit. I would like to detect when user's drawings are intersecting. I tried to following code but it doesn't work. It seems sprite kit is not saving all the points: override func touchesMoved(touches: NSSet, withEvent event: UIEvent) { /* Called when a touch begins */ touch = touches.anyObject() as UITouch! for drawingPoint in drawingPoints{ if(touch.locationInNode(self) == drawingPoint){println(true)} } drawingPoints.append(touch.locationInNode(self)) } 回答1: Here is a

Create \\(Use) SKView as \\(in a) factory \\(static class)

倖福魔咒の 提交于 2019-11-29 12:41:39
I want to make an SKView I can use as a factory to make SKShapeNodes and "render" them to textures. But I can't find how I would initialise such a thing, and am having no luck, at all. How do I make a standalone SKView for this purpose? Or is there a better way to do this that avoids using the gamescene? Here's my FUTILE Effort at making a factory, this complains that texture(from: ) is ambiguous . I have no idea what that means. import SpriteKit class Make: SKView{ static func circle() -> SKSpriteNode { let myShapeNode = SKShapeNode(circleOfRadius: 100) myShapeNode.fillColor = SKColor