Skip to content

Instantly share code, notes, and snippets.

@videlais
Created October 15, 2013 02:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save videlais/6985640 to your computer and use it in GitHub Desktop.
Save videlais/6985640 to your computer and use it in GitHub Desktop.
ActionScript 3 Example 2 PlayerSprite
package
{
/**
* ...
* @author Dan Cox
*/
import org.flixel.*;
public class PlayerSprite extends FlxSprite
{
public function PlayerSprite(X:Number = 0, Y:Number = 0)
{
super(X, Y);
makeGraphic(100, 100);
}
override public function update():void
{
super.update();
if (FlxG.keys.W || FlxG.keys.UP)
{
y -= 3;
}
else if (FlxG.keys.S || FlxG.keys.DOWN)
{
y += 3;
}
else if (FlxG.keys.A || FlxG.keys.LEFT)
{
x -= 3;
}
else if (FlxG.keys.D || FlxG.keys.RIGHT)
{
x += 3;
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment