Skip to content

Instantly share code, notes, and snippets.

View sarah-j-smith's full-sized avatar

Sarah Smith sarah-j-smith

View GitHub Profile
QString MacUtils::getOpenFileName(QWidget *parent, const QString &title, const QString &dirName, const QString &filter, MacUtils::OpenType openType)
{
qDebug() << Q_FUNC_INFO << "dirName:" << dirName;
NSOpenPanel *panel = [NSOpenPanel openPanel];
QWidget *window = parent->window();
Q_ASSERT_X(window != 0, Q_FUNC_INFO, "Expected non-nil window");
Q_ASSERT_X(window->isWindow(), Q_FUNC_INFO, "Expected window");
NSView *v = reinterpret_cast<NSView *>(window->winId());
NSWindow *macWindow = [v window];
@sarah-j-smith
sarah-j-smith / TwoColorText.h
Last active August 29, 2015 14:05
Cocos2D CCLabelBMFont that can display two colours, by surrounding [highlighted] sections in [square brackets] for emphasis.
//
// TwoColorText.h
// SpaceBotAlpha
//
// Created by Sarah Smith on 26/08/2014.
// Copyright (c) 2014 Smithsoft Pty Ltd. All rights reserved.
// License: https://creativecommons.org/licenses/by-sa/3.0/au/
//
// Implemented from ideas seen here: http://whitesponge.com/blog/dual-colored-labels-with-cocos2d/
// but done so as to handle multiple sections of [highlighted] text [not just one].
//
// AnimatedTutorial.h
// SpaceBotAlpha
//
// Created by Sarah Smith on 26/09/2014.
// Copyright (c) 2014 Smithsoft Pty Ltd. All rights reserved.
//
// Show a movie - eg a .mp4 file - in a windowed frame of a Cocos2D scene.
// Has an "OK, got it" button which dismisses the video. If the video has
@sarah-j-smith
sarah-j-smith / String+Quest.swift
Created January 25, 2015 03:30
Swift String Extensions
//
// StringFunctions.swift
// Quest
//
// Created by Sarah Smith on 24/01/2015.
// Copyright (c) 2015 Sarah Smith.
// MIT License.
import Foundation
@sarah-j-smith
sarah-j-smith / CCColor+HexString.h
Last active August 29, 2015 14:15
Category on Cocos2D's CCColor class to create a color from a Hex string.
//
// CCColor+HexString.h
// SpaceBotAlpha
//
// Created by Sarah Smith on 19/02/2015.
// Copyright (c) 2015 Smithsoft. All rights reserved.
//
#import <Foundation/Foundation.h>
@sarah-j-smith
sarah-j-smith / bmfont.sh
Created February 26, 2015 01:27
GlyphDesigner Cocos2D SpriteBuilder bmftonts script
#!/bin/bash
if [ -z "$1" ]; then
echo "Usage: $0 BmFontName"
exit 1
fi
FONT_NAME="$1"
FONT_NAME=$(basename $FONT_NAME .GlyphProject)
@sarah-j-smith
sarah-j-smith / README.md
Last active August 29, 2015 14:26
Swift+SpriteKit does a good job with its default string descriptions of nodes; so just do something like this to get a nice log dump of your scene

Usage

Call with myScene.printNodeTree()

Example Output

Scene (SKView ignores sibling order)
<SKScene> name:'Game Scene' frame:{{0, 0}, {768, 1024}}

name:'Background Layer' position:{0, 0} accumulatedFrame:{{96, 0}, {576, 1024}}

@sarah-j-smith
sarah-j-smith / PeformanceTimer.swift
Created August 6, 2015 23:05
Time Profiling in Swift
//
// PerformanceTimer.swift
// WordMonsters
//
// Created by Sarah Smith on 8/6/15.
// Copyright (c) 2015 Sarah Smith. All rights reserved.
//
import Foundation
@sarah-j-smith
sarah-j-smith / FaderStateMachine.swift
Last active September 12, 2015 07:38
Fade an SKNode in and out using a GKStateMachine
//
// FaderStateMachine.swift
// WordMonsters
//
// Created by Sarah Smith on 9/12/15.
// Copyright © 2015 Sarah Smith. All rights reserved.
//
import Foundation
import GameplayKit
@sarah-j-smith
sarah-j-smith / Button.swift
Created October 30, 2015 01:33
Create a disabled appearance for a button or other SKNode
import Foundation
import SpriteKit
class Button : SKEffectNode
{
var buttonEnabled: Bool = true {
didSet {
if oldValue != buttonEnabled
{
updateEnabled()