Skip to content

Instantly share code, notes, and snippets.

@schonstal
Created February 28, 2012 01:29
Show Gist options
  • Save schonstal/1928378 to your computer and use it in GitHub Desktop.
Save schonstal/1928378 to your computer and use it in GitHub Desktop.
pseudocode example for LordNed
package
{
import org.flixel.*;
public class PlayState extends FlxState
{
private var somethingPrivate:Number = 0;
private var player:Player;
override public function create():void {
player = new Player(0,0);
player.addOnJumpCallback(function():void { somethingPrivate += 5; });
}
}
}
package
{
import org.flixel.*;
public class Player extends FlxSprite
{
var callbacks:Array = new Array();
public function jump():void {
for each(var callback:Function in callbacks) {
callback();
}
}
public function addOnJumpCallback(callback:Function) {
callbacks.push(callback);
}
public override function update():void {
if(FlxG.keys.X) jump();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment