skshapenode

Set SKShapeNode frame to calculateAccumutedFrame

别等时光非礼了梦想. 提交于 2019-12-22 12:33:14
问题 This issue has been happening for days: I cannot set the specific frame I need. I need my SKShapeNode frame to be the bounding box around a circle so that it is an inscribed circle to the frame. The blue is the current frame and the red is the frame I want it to be. I am creating the SKShapeNode like this: init(level: Int, from: SKSpriteNode, fromScene: GameScene) { self.level = level self.from = from self.fromScene = fromScene bezierPath = UIBezierPath(arcCenter: CGPoint.zero, radius:

Fill SKShapeNode with pattern image

梦想与她 提交于 2019-12-22 11:05:15
问题 I'm trying to fill a SKShapeNode with an Image/pattern but I'm still unsuccessfull. Can you help me solving this or giving me an alternative? I want to create a collidable custom shape (from any SpriteKit kind) filled with a pattern image. I've tried the following: UIBezierPath *path = [[UIBezierPath alloc] init]; [path addArcWithCenter:CGPointMake(0.0, 0.0) radius:50.0 startAngle:0.0 endAngle:(M_PI*2.0) clockwise:YES]; SKShapeNode *shape = [[SKShapeNode alloc] init]; UIImage *patternImg =

SKShapeNode filltexture() does not display image

我们两清 提交于 2019-12-22 05:27:01
问题 I want to create a circle that whose content is an image (.png), and based on the SKShapeNode class reference, I thought that I could use SKShapeNode.filltexture() function to set the texture to the image. But when i run the code below, I get the circle, but the image of the "cat-black" I am trying to load doesn't show. I checked that my Image.Assets have the image with the correct name, so something else is up. Any ideas? I attached the output below: func newCircle(photo:String, position

Swift: Make translucent overlapping lines of the same color not change color when intersecting

泄露秘密 提交于 2019-12-21 18:59:44
问题 Currently I have drawn 2 lines on the screen which are the same color but both have an alpha value less than 1. When these lines intersect, the intersection is a different color than the rest of the lines. There was a previous post addressing the same issue: swift drawing translucent lines, how to make overlapping parts not getting darker? However, this post wasn't sufficiently answered. I draw the lines currently like this: var points = [CGPoint]() points = [CGPoint(x: -100, y: 100), CGPoint

Rotating an SKShapeNode along its center

倾然丶 夕夏残阳落幕 提交于 2019-12-21 13:42:25
问题 I have an SKShapeNode (rectangle in this case) which I am trying to rotate along its center. However it is rotating along the screen's bottom left point. Since I cannot set an anchor point for SKShapeNode, how can I achieve my requirement (to rotate the shape along its centre). This is the code I'm trying. let rectangle = SKShapeNode() rectangle.path = UIBezierPath(rect: CGRectMake(view.frame.width/4, view.frame.height/2, view.frame.width/2, view.frame.width/2)).CGPath rectangle.fillColor =

no designated init for SKShapeNode(circleOfRadius: radius)

非 Y 不嫁゛ 提交于 2019-12-19 05:11:54
问题 I'm trying to create a subclass of SKShapeNode in swift as SKShapeNode(circleOfRadius: radius) but there is no designated init for it. Anyone have any workarounds or info about why? I'm not sure if this is a bug or intentional. I found this video demonstrating a workaround for SKSpriteNode but its not working for me. https://skillsmatter.com/skillscasts/5695-how-to-subclass-a-skspritenode Overall i am trying to make a subclass for an SKShapeNode that i can then subclass from again to have

SKShapeNode consuming too much memory and slowing down animation -Spritekit iOS

筅森魡賤 提交于 2019-12-18 13:48:10
问题 I am using SKShapeNode to to create a mountain like object . I use CGMutablePathRef to give the points to my path SKShapeNode *shapenode = [[SKShapeNode alloc] init]; CGMutablePathRef path = CGPathCreateMutable(); CGPathMoveToPoint(path, NULL, 0, 0); ...... for (int i = 0; i < [refData count];i++) { CGPathAddLineToPoint(path, NULL, ((float)i/[refData count])*screenWidthBoundry, [[refData objectAtIndex:i] doubleValue]); } CGPathAddLineToPoint(path, NULL, screenWidthBoundry, 0);

Multiple skshapenode in one draw?

假如想象 提交于 2019-12-18 05:23:07
问题 Hi I have drawn skshapenodes connecting the nodes in my graph for my visual a* representation. for(int x=0; x<64; x++) { for(int y=0; y<48; y++) { PathFindingNode *node = [[gridToDraw objectAtIndex:x] objectAtIndex:y]; for(int i=0; i< node.connections.count; i++) { PathFindingNode *neighbor = [node.connections objectAtIndex:i]; SKShapeNode *line = [SKShapeNode node]; CGMutablePathRef pathToDraw = CGPathCreateMutable(); CGPathMoveToPoint(pathToDraw, NULL, node.position.x, node.position.y);

Draw a hole in a rectangle with SpriteKit?

China☆狼群 提交于 2019-12-17 19:03:19
问题 How to draw a hole in a rectangle? I want to draw a rectangle which has a empty hole inside it and the background can be show. I am using SKShapeNode to create a rectangle, but I have no idea how to make a hole (circle) inside it. This is what I run your code, but my circle is not empty, the circle is black, I want it to be empty. Is there any mistake I didn't mention? 回答1: Here's the code. import SpriteKit class GameScene: SKScene { override func didMove(to view: SKView) { let effect =

Draw a hole in a rectangle with SpriteKit?

浪尽此生 提交于 2019-12-17 19:01:38
问题 How to draw a hole in a rectangle? I want to draw a rectangle which has a empty hole inside it and the background can be show. I am using SKShapeNode to create a rectangle, but I have no idea how to make a hole (circle) inside it. This is what I run your code, but my circle is not empty, the circle is black, I want it to be empty. Is there any mistake I didn't mention? 回答1: Here's the code. import SpriteKit class GameScene: SKScene { override func didMove(to view: SKView) { let effect =