4

In Xcode 6 beta 2 it worked fine, but in beta 4 it doesn't work anymore. Does anyone know what's behind this mystery?

let circle = SKShapeNode(circleOfRadius: 125);
circle.strokeColor = UIColor(red: 255, green: 255, blue: 255, alpha: 1.0);
circle.lineWidth = 4
self.addChild(circle);

In beta 4 nothing can be seen.

Thanks for your help in advance.

Andrew
  • 15,357
  • 6
  • 66
  • 101
Velykovits
  • 223
  • 2
  • 13
  • 2
    possible duplicate of [How to initialize UIColor from RGB values properly?](http://stackoverflow.com/questions/8023916/how-to-initialize-uicolor-from-rgb-values-properly) and many other similar questions: The red/green/blue parameters are floating point numbers **in the range 0.0 .. 1.0**. – Martin R Jul 25 '14 at 08:41
  • Thanks Martin, I give it it try. – Velykovits Jul 25 '14 at 08:53
  • 1
    @MartinR - despite the mistake in using 255 instead of 1.0, he seems to be right - it doesn't work (using 255 would default to 1.0 anyway) - the circle is filled (if you add that in), but not stroked, even if you make all of the parameters CGFloats in the correct range... – Grimxn Jul 25 '14 at 08:53
  • @Grimxn: OK, I have retracted my closing vote. – Martin R Jul 25 '14 at 08:56
  • Maybe you are misunderstanding stroke? It's not a fill pattern but the outline of the path. Try setting both fill and stroke color. – CodeSmile Jul 25 '14 at 11:31
  • I tried it with the correct color format but still no luck with the stroke. It fills the circle, but no outline at all and that is what I need. I used both the fill and stroke too: circle.fillColor = UIColor(red: 1.0, green: 1.0, blue: 1.0, alpha: 0.5); circle.strokeColor = UIColor(red: 1.0, green: 1.0, blue: 1.0, alpha: 1.0); – Velykovits Jul 25 '14 at 16:26
  • iOS 8 beta 3 and 4 have Sprite Kit issues. The Apple Developer forums have some additional information on it. – sangony Jul 25 '14 at 22:52
  • I have similar problems with SKShapeNodes in Xcode 6 beta 4. Color-transparency issues + stroke (color/lineWidth/glowWidth) issues, etc. – sabiland Jul 28 '14 at 09:10
  • I guess the same problem exists also in Xcode 6 beta 5. – sabiland Aug 06 '14 at 05:27

1 Answers1

2

This is a common issue with Xcode 6 Beta 4 when using the simulator. It renders fine when using an actual device. See this developer forums thread. It is worth noting that the issue is exclusive to stroking in that setting circle.fillColor still fills the circle (or whatever your SKShapeNode is drawing) correctly.

Also keep in mind that when initializing a UIColor with RGB values the RGB values must be between (inclusive) 0.0 and 1.0.

circle.strokeColor = UIColor(red: 1.0, green: 1.0, blue: 1.0, alpha: 1.0);

Or alternatively use the preset:

circle.strokeColor = UIColor.whiteColor()
Community
  • 1
  • 1
Andrew
  • 15,357
  • 6
  • 66
  • 101