Skip to content

Instantly share code, notes, and snippets.

View PrimaryFeather's full-sized avatar

Daniel Sperl PrimaryFeather

View GitHub Profile
@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 / Gauge.as
Last active February 29, 2020 09:35
This Starling 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.
package starling.extensions
{
import starling.display.Image;
import starling.display.Sprite;
import starling.textures.Texture;
import starling.utils.MathUtil;
public class Gauge extends Sprite
{
private var _image:Image;
@PrimaryFeather
PrimaryFeather / Polygon.as
Last active July 31, 2017 14:53
A custom display object for Starling, rendering a regular n-sided polygon.
package utils
{
import com.adobe.utils.AGALMiniAssembler;
import flash.display3D.*;
import flash.geom.*;
import starling.core.RenderSupport;
import starling.core.Starling;
import starling.display.DisplayObject;
@PrimaryFeather
PrimaryFeather / ClippedSprite.as
Created April 19, 2012 17:02
Simple Sprite subclass with a rectangular mask in stage coordinates
package starling.extensions
{
import flash.display3D.Context3D;
import flash.geom.Point;
import flash.geom.Rectangle;
import starling.core.RenderSupport;
import starling.core.Starling;
import starling.display.DisplayObject;
import starling.display.Sprite;
@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 / 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 / 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 / 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 / gist:5983685
Last active February 29, 2020 09:35
Water distortion filter, implemented with Starling's "DisplacementMapFilter".
private function addDistortionTo(target:DisplayObject):void
{
var offset:Number = 0;
var scale:Number = Starling.contentScaleFactor;
var width:int = target.width;
var height:int = target.height;
var perlinData:BitmapData = new BitmapData(width * scale, height * scale, false);
perlinData.perlinNoise(200*scale, 20*scale, 2, 5, true, true, 0, true);
@PrimaryFeather
PrimaryFeather / cloneObject
Last active June 11, 2018 11:18
Utility method to clone an AS3 object of any type.
package com.gamua.flox.utils
{
import flash.utils.describeType;
import flash.utils.getQualifiedClassName;
/** Creates a deep copy of the object.
* Beware: all complex data types will become mere 'Object' instances. Supported are only
* primitive data types, arrays and objects. Any properties marked with "NonSerialized"
* meta data will be ignored by this method.
*