skshapenode

Folder of images: create and fill SKShapeNodes, 1 of each

回眸只為那壹抹淺笑 提交于 2019-11-28 06:05:29
问题 Is it possible to create a folder and have SpriteKit go through that folder, find each image (regardless of name), and create a SKShapeNode for each in that folder (regardless of how many there are)? Assume all images are the same size, and all .png files ready to be used as unique images as textures for filling SKShapeNodes, and that all SKShapeNodes will be the same size. I want to know, once done, how many shapes have been created, and have them uniquely named based on the name of the

Poor performance with SKShapeNode in Sprite Kit

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-27 08:07:41
I'm making a " Achtung die kurve "-clone in Sprite Kit. For the constantly moving lines/players I'm using A CGMutablePathRef along with an SKShapeNode. In the update method I'm doing this // _lineNode is an instance of SKShapeNode and path is CGMutablePathRef CGPathAddLineToPoint(path, NULL, _xPos, _yPos); _lineNode.path = path; to add to the line. The update method is also updating the _xPos and _yPos constantly to make it grow. I guess what I'm really asking is is there another, more efficient way of drawing the lines, since the way I'm doing it now drops the frame rate way too much after a

SpriteKit Swift Node Count issues

人走茶凉 提交于 2019-11-27 07:21:27
问题 The simulator shows the node count, that there are 2 nodes. But why is that? Since there is only one var(ball). Is there a way to create a circle without having it be double the nodes. class GameScene: SKScene { var ball = SKShapeNode(circleOfRadius: 50) override func didMoveToView(view: SKView) { ball.position = CGPointMake(self.frame.size.width / 2, self.frame.size.height / 2) ball.fillColor = SKColor.blackColor() self.addChild(ball) } 回答1: This is happening because SKShapeNode fillColor is

How to draw a line in Sprite-kit

試著忘記壹切 提交于 2019-11-27 07:13:23
How can one draw a line in Sprite-kit? For example if I want to draw a line in cocos2d, I could easily using ccDrawLine(); Is there an equivalent in sprite-kit? Rajneesh071 Using SKShapeNode you can draw line or any shape. SKShapeNode *yourline = [SKShapeNode node]; CGMutablePathRef pathToDraw = CGPathCreateMutable(); CGPathMoveToPoint(pathToDraw, NULL, 100.0, 100.0); CGPathAddLineToPoint(pathToDraw, NULL, 50.0, 50.0); yourline.path = pathToDraw; [yourline setStrokeColor:[SKColor redColor]]; [self addChild:yourline]; Equivalent for Swift 4: var yourline = SKShapeNode() var pathToDraw =

Poor performance with SKShapeNode in Sprite Kit

时光怂恿深爱的人放手 提交于 2019-11-26 14:06:14
问题 I'm making a "Achtung die kurve"-clone in Sprite Kit. For the constantly moving lines/players I'm using A CGMutablePathRef along with an SKShapeNode. In the update method I'm doing this // _lineNode is an instance of SKShapeNode and path is CGMutablePathRef CGPathAddLineToPoint(path, NULL, _xPos, _yPos); _lineNode.path = path; to add to the line. The update method is also updating the _xPos and _yPos constantly to make it grow. I guess what I'm really asking is is there another, more

How to draw a line in Sprite-kit

有些话、适合烂在心里 提交于 2019-11-26 13:05:19
问题 How can one draw a line in Sprite-kit? For example if I want to draw a line in cocos2d, I could easily using ccDrawLine(); Is there an equivalent in sprite-kit? 回答1: Using SKShapeNode you can draw line or any shape. SKShapeNode *yourline = [SKShapeNode node]; CGMutablePathRef pathToDraw = CGPathCreateMutable(); CGPathMoveToPoint(pathToDraw, NULL, 100.0, 100.0); CGPathAddLineToPoint(pathToDraw, NULL, 50.0, 50.0); yourline.path = pathToDraw; [yourline setStrokeColor:[SKColor redColor]]; [self