An SKShapeNode object draws a shape defined by a Core Graphics path
Questions tagged [skshapenode]
286 questions
0
votes
0 answers
Swift: SKShapeNode's proportion of view: how to determine?
In Swift, I would like to calculate how much in percentages the red SKShapeNode is of the (blue) SKScene layer. Can't find methods for determining shape area. Is there a way to calculate the area of SKShapeNode?

user3673836
- 591
- 1
- 9
- 23
0
votes
1 answer
Extend SkShapeNode to get rectangle position in n x m matrix
I'm using SKShapeNode to add rectangles in a n x m matrix. Now I want to store the n x m
position in the SKShapeNode. Of course I could simply use the .name property and store the n x m position as string. This has the disadvantage that when I'm…

andreaspfr
- 2,298
- 5
- 42
- 51
0
votes
1 answer
How to manipulate a sprite kit's SKNode?
I have coded a starry sky as follows. Now I would like to remove a star when a user touches it. The following code however removes all the stars on the sky. How can I access a single star node to manipulate it?
override func didMoveToView(view:…

user3673836
- 591
- 1
- 9
- 23
0
votes
1 answer
setFillColor with patternImage cocos2d not working
I am trying to fill a SKShapeNode with an image. I have tried quite a few things but can't get it to work. The game loads, but nothing appears on the screen. Here is my recent code.
self.circle = [[SKShapeNode alloc] init];
UIBezierPath…

user2632573
- 105
- 1
- 8
0
votes
1 answer
Is SKShapeNode strokeColor broken on ios8?
Using the simulator (iPhone 4s,5,6), I've discovered that on iOS7 the following code works fine, but on iOS8 the stroke is not drawn. (w and h are defined elsewhere).
SKShapeNode* userGuessSpace = [SKShapeNode node];
CGPathRef ref =…

GilesDMiddleton
- 2,279
- 22
- 31
0
votes
2 answers
Scale a trapezoidal SKShapeNode by width while preserving 45-45-90 triangles on sides
I have an SKShapeNode which is supposed to be a paddle in a breakout-style game which I would like to scale in width by some factor.
It looks like this:
After I run
[SKAction scaleXBy:3.f / 2.f y:1.0 duration:1.0],
it looks like this (ignore the…

michaelsnowden
- 6,031
- 2
- 38
- 83
0
votes
2 answers
Drawing line with Touch iOS Sprite Kit
Im using the following code to draw lines in my sprite kit scene but nothing shows up. But the node counts goes up. Can anyone see what could be the problem. Ive been fighting with this code forever
- (void)touchesBegan:(NSSet *)touches…

4GetFullOf
- 1,738
- 4
- 22
- 47
0
votes
2 answers
NSNumber is not a subtype of UInt8
I am trying to do some fairly simple SKShapeNode math to set the position of a shape node. It looks like this:
for var i = 0; i < 6; i++ {
var pip: Pip = pips[i]
// set position
let x: CGFloat = tray2.frame.size.width -…

zeeple
- 5,509
- 12
- 43
- 71
0
votes
1 answer
How to limit the size of line made by touch within an app
i've created a code that creates a line of unlimited size by touch and i'm wondering how to restrict the size such that the beginning and end of the line can be a small distance to a maximum set distance apart?
The code i used was:
pathToDraw =…

bob
- 1
- 1
0
votes
0 answers
Implementing bodyWithBodies in Sprite Kit
I am using Apple's Sprite Kit to create a game, and currently I have drawn an SKShapeNode object that looks similar to the following:
My actual sprite has rounded edges, but for simplicity, I am trying to get everything working with this shape…

wgrenard
- 187
- 12
0
votes
1 answer
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:
let myNode = SKShapeNode()
let lineToDraw = CGPathCreateMutable()
CGPathMoveToPoint(lineToDraw, nil, 0,…

Kate Bertelsen
- 3,900
- 5
- 24
- 18
0
votes
1 answer
SKShapeNode ellipseInRect, sprite does not appear in scene
I'm trying to create an ellipse in the center of my scene:
let center = (CGRectGetMidX(view.scene.frame), CGRectGetMidY(view.scene.frame))
let size = (view.scene.frame.size.width * 0.3, view.scene.frame.size.height * 0.3)
let ellipse = SKShapeNode…

JuJoDi
- 14,627
- 23
- 80
- 126
0
votes
0 answers
Animating change of SKShapeNode fill color?
Below is the code I'm having trouble with :
SKShapeNode* backgroundRect = [SKShapeNode shapeNodeWithRect:self.frame];
backgroundRect.fillColor = [UIColor whiteColor];
SKAction* colorBackground = [SKAction customActionWithDuration:0.5f…

Marcus Buffett
- 1,289
- 1
- 14
- 32
0
votes
0 answers
How to synchronize circle (with SKAction by SKShapeNode) to ball (by SKShapeNode)?
I try to synchronize circle (create with SKAction by SKShapeNode) to ball (create by SKShapeNode).
Here is this code. But it couldn't work well.
What should I do?
-(void)makeContents{
//make ground
UIBezierPath *groundPath = [UIBezierPath…

user3686701
- 1
- 1
0
votes
0 answers
Sprite Kit - Sprite and Edge have large gap between them when colliding [See screenshot]
As you can see in the screenshot below, there is a large gap between both the circle (a SKShapeNode) and the line (also a SKShapeNode).
Naturally, both of these items should be touching when they collide.
Here is my code:
-…

Adam Carter
- 4,741
- 5
- 42
- 103