Skip to content

Instantly share code, notes, and snippets.

View PrimaryFeather's full-sized avatar

Daniel Sperl PrimaryFeather

View GitHub Profile
@PrimaryFeather
PrimaryFeather / sparrow-distortion.m
Created March 21, 2014 10:51
Water distortion filter, implemented with Sparrow's "DisplacementMapFilter".
- (void)addDistortionTo:(SPDisplayObject *)target
{
float scale = Sparrow.contentScaleFactor;
NSURL *url = scale == 1.0f ?
[NSURL URLWithString:@"http://i.imgur.com/n95LSGb.jpg"] :
[NSURL URLWithString:@"http://i.imgur.com/QRXLvws.jpg"];
[SPTexture loadFromURL:url generateMipmaps:NO scale:scale
onComplete:^(SPTexture *texture, NSError *outError)
{
@PrimaryFeather
PrimaryFeather / Sparrow.podspec
Last active August 29, 2015 14:03
CocoaPods podspec for Sparrow — RFC =)
Pod::Spec.new do |s|
s.name = "Sparrow"
s.version = "2.1"
s.summary = "The Open Source Game Engine for iOS"
s.description =
<<-DESC
Sparrow is a pure Objective-C library for game developers, built from ground up
for iOS. If you have already worked with Adobe™ Flash or Starling, you will feel
right at home: Sparrow uses the same concepts and naming schemes.
@PrimaryFeather
PrimaryFeather / SXGauge.h
Last active September 25, 2015 04:58
This Sparrow extension class displays a texture, trimmed to its left side, depending on a ratio. This can be used to create a progress bar or a rest-time display.
#import <Foundation/Foundation.h>
#import "Sparrow.h"
/// An SXGauge displays a texture, trimmed to its left side, depending on a ratio.
/// This can be used to display a progress bar or a time gauge.
@interface SXGauge : SPSprite
/// Indicates how much of the texture is displayed. Range: 0.0f - 1.0f
@property (nonatomic, assign) float ratio;
@PrimaryFeather
PrimaryFeather / generate_code.as
Created May 23, 2012 11:08
The code generator used to create the 'QuadBatch.getImageProgramName' method in the Starling Framework.
var tab:String = " ";
for each (var tinted:Boolean in [true, false])
{
trace(tinted ? "if (tinted)" : "else");
trace("{");
for each (var mipMap:Boolean in [true, false])
{
trace(tab, mipMap ? "if (mipMap)" : "else");
trace(tab, "{");
for each (var repeat:Boolean in [true, false])
@PrimaryFeather
PrimaryFeather / convert_members.rb
Created December 5, 2015 11:51
A small Ruby script that modifies source code so that variables in the form "mName" are changed to "_name"
#!/usr/bin/ruby
if ARGV.count < 1
puts "Usage: #{script_name} source_path"
puts " (e.g. ../src/starling/)"
exit
end
search_path = ARGV[0]
@PrimaryFeather
PrimaryFeather / Polygon.h
Last active December 16, 2015 01:09
An example for a custom display object for the Sparrow Framework.
#import "SPDisplayObject.h"
@interface Polygon : SPDisplayObject
- (id)initWithRadius:(float)radius numEdges:(int)numEdges color:(uint)color;
- (id)initWithRadius:(float)radius numEdges:(int)numEdges;
@property (nonatomic, assign) int numEdges;
@property (nonatomic, assign) float radius;
@property (nonatomic, assign) uint color;
@PrimaryFeather
PrimaryFeather / TexturedPolygon.h
Last active December 17, 2015 22:09
An example for a custom display object for the Sparrow Framework - this time with a texture.
#import "SPDisplayObject.h"
@interface TexturedPolygon : SPDisplayObject
- (id)initWithRadius:(float)radius numEdges:(int)numEdges texture:(SPTexture *)texture;
@property (nonatomic, assign) int numEdges;
@property (nonatomic, assign) float radius;
@property (nonatomic, strong) SPTexture *texture;
@property (nonatomic, assign) uint color;
@PrimaryFeather
PrimaryFeather / SPPoolObjectBenchmark.m
Last active December 26, 2015 10:28
Small benchmark code to test performance of Sparrow's "SPPoolObject".
#import <QuartzCore/QuartzCore.h> // for CACurrentMediaTime()
- (void)runPoolBenchmark
{
double startTime, endTime;
const int NumObjects = 1000000;
typedef SPMatrix SPObject;
[SPObject purgePool];
NSMutableArray *array = [NSMutableArray arrayWithCapacity:NumObjects];
@PrimaryFeather
PrimaryFeather / deploy_to_mobile.sh
Created May 22, 2013 16:43
Simple shell script to deploy an app to a mobile device; depending on the file extension, either iOS or Android. Call the script with the application package as first argument; also be sure to update "air_sdk" to point to an AIR SDK of at least 3.5.
#!/bin/bash
air_sdk="/path/to/air_sdk"
adb="$air_sdk/lib/android/bin/adb"
adt="$air_sdk/bin/adt"
if [ ${1: -4} == ".ipa" ]
then
"$adt" -installApp -platform ios -package $1
else
@PrimaryFeather
PrimaryFeather / ColorOffsetFilter.as
Last active December 15, 2016 17:34
Basic implementation of the ColorOffsetFilter described in the Starling manual.
// =================================================================================================
//
// Starling Framework
// Copyright Gamua. All Rights Reserved.
//
// This program is free software. You can redistribute and/or modify it
// in accordance with the terms of the accompanying license agreement.
//
// =================================================================================================