Created
February 28, 2012 01:29
-
-
Save schonstal/1928378 to your computer and use it in GitHub Desktop.
pseudocode example for LordNed
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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