Skip to content

Instantly share code, notes, and snippets.

View PrimaryFeather's full-sized avatar

Daniel Sperl PrimaryFeather

View GitHub Profile
@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 / 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 / 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 / TextureMaskStyle.as
Last active November 6, 2023 10:40
A MeshStyle for Starling 2 that discards texels with an alpha value below a certain threshold. This makes it perfect for arbitrarily shaped stencil masks.
// =================================================================================================
//
// Starling Framework
// Copyright 2011-2016 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.
//
// =================================================================================================
@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.
//
// =================================================================================================
@PrimaryFeather
PrimaryFeather / ColorOffsetFilter.as
Last active April 6, 2017 01:26
The revised ColorOffsetFilter of the tutorial from the Starling manual; now with fixed PMA handling.
// =================================================================================================
//
// Starling Framework
// Copyright Gamua GmbH. 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.
//
// =================================================================================================
@PrimaryFeather
PrimaryFeather / ColorOffsetStyle.as
Last active February 16, 2018 08:18
A MeshStyle for Starling 2 that allows to add an offset to each color channel of a mesh, as described in the Starling manual.
// =================================================================================================
//
// Starling Framework
// Copyright Gamua GmbH. 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.
//
// =================================================================================================
@PrimaryFeather
PrimaryFeather / MultiTextureStyle.as
Last active October 4, 2020 10:03
A "MeshStyle" for Starling that allows batching of multiple textures in one draw call.
// =================================================================================================
//
// Starling Framework
// Copyright Gamua GmbH. 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.
//
// =================================================================================================
@PrimaryFeather
PrimaryFeather / TestDeviceScaleFactors.as
Last active February 16, 2019 03:46
This code tests the logic used to come up with the stage size and content scale factor on typical devices.
package
{
import flash.display.Sprite;
public class TestDeviceScaleFactors extends Sprite
{
public function TestDeviceScaleFactors()
{
var testSettings:Array = [
{ name: "iPhone 3GS", dpi: 163, resX: 320, resY: 480 },