Skip to content

Instantly share code, notes, and snippets.

@wolfspider
Created December 27, 2015 02:01
Show Gist options
  • Select an option

  • Save wolfspider/ad717f49ed6317fa95e0 to your computer and use it in GitHub Desktop.

Select an option

Save wolfspider/ad717f49ed6317fa95e0 to your computer and use it in GitHub Desktop.
Swift Rounded Rect Playground
import SpriteKit
import XCPlayground
let view:SKView = SKView(frame: CGRectMake(0, 0, 1024, 768))
XCPlaygroundPage.currentPage.liveView = view
let scene:SKScene = SKScene(size: CGSizeMake(1024, 768))
scene.scaleMode = SKSceneScaleMode.AspectFit
view.presentScene(scene)
//Add something to it!
let redBox:SKSpriteNode = SKSpriteNode(color: SKColor.redColor(), size:CGSizeMake(300, 300))
redBox.position = CGPointMake(512, 384)
redBox.runAction(SKAction.repeatActionForever(SKAction.rotateByAngle(3, duration: 2)))
let redShape:SKShapeNode = SKShapeNode(rectOfSize: CGSizeMake(100, 100))
redShape.position = CGPointMake(200, 200)
redShape.glowWidth = 1.5
redShape.strokeColor = SKColor.redColor()
redShape.setScale(0.5)
let redTex:SKTexture = view.textureFromNode(redShape)!
redBox.texture = redTex
//redShape.removeFromParent()
redShape.path = nil
scene.addChild(redBox)
redBox.position = CGPointMake(200, 200)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment