This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void main() { | |
// Find the pixel at the coordinate of the actual texture | |
vec4 val = texture2D(u_texture, v_tex_coord); | |
// If the alpha value of that pixel is 0.0 | |
if (val.a == 0.0) { | |
// Turn the pixel green | |
gl_FragColor = vec4(0.0,1.0,0.0,1.0); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let sprite = self.childNodeWithName("targetSprite") as! SKSpriteNode | |
let shader = SKShader(fileNamed: "shader1.fsh") | |
sprite.shader = shader |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void main() { | |
gl_FragColor = vec4(0.0,1.0,0.0,1.0); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SpriteKit | |
class GameData : NSObject, NSCoding { | |
/// Each scene always knows what scene should come next. | |
/// So, by storing the current scene, we can just resume that scene when the game is reloaded | |
/// If the user quits on a level, use logic to show world map instead | |
/// NOTE** -- save SceneObject instead? so that userData is remembered, and it just pass this to scene manager? | |
var currentScene : String = "MainMenu" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 5 - starburst out | |
let filter = CIFilter(name: "CIFlashTransition", withInputParameters: ["inputCenter":CIVector(x: 600, y: 900)]) | |
let transition = SKTransition(CIFilter: filter, duration: 2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class GameData : NSObject, NSCoding { | |
/// Data to save | |
var variableA : Int = 1 | |
var variableB : Int = 2 | |
var variableC : Int = 3 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CutsceneAction { | |
var finishEarly : Bool = false | |
func timingFunc(time:Float) -> Float { | |
if(self.finishEarly) { | |
return 1.0 | |
} | |
else { | |
return time |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func timingFunc(time:Float) -> Float { | |
return 1.0 | |
} | |
let moveAction = SKAction.moveToX(500, duration: 0.2) | |
moveAction.timingFunction = timingFunc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if let font = UIFont(name: "DamascusSemiBold", size: 24) { | |
let textFontAttributes = [ | |
NSFontAttributeName : font, | |
// Note: SKColor.whiteColor().CGColor breaks this | |
NSForegroundColorAttributeName: UIColor.whiteColor(), | |
NSStrokeColorAttributeName: UIColor.blackColor(), | |
// Note: Use negative value here if you want foreground color to show | |
NSStrokeWidthAttributeName: -3 | |
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SpriteKit | |
class UpdateService { | |
/// Handle on current SKScene | |
let scene : Level | |
/// Array of callbacks to be called each time the updateLoopRuns | |
var updateListeners : Array<((CFTimeInterval) -> ())> = [] | |