Skip to content

Instantly share code, notes, and snippets.

@DleanJeans
Last active November 9, 2016 11:40
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 DleanJeans/f3c0261bc98e078b23eae92fcd1fef9a to your computer and use it in GitHub Desktop.
Save DleanJeans/f3c0261bc98e078b23eae92fcd1fef9a to your computer and use it in GitHub Desktop.
FlxSwipe Test
package;
import flixel.FlxG;
import flixel.FlxSprite;
import flixel.FlxState;
import flixel.input.FlxSwipe;
import flixel.util.FlxSpriteUtil;
class PlayState extends FlxState {
var canvas:FlxSprite;
override public function create() {
bgColor = 0xFFFFFFFF; // white
canvas = new FlxSprite();
canvas.makeGraphic(FlxG.width, FlxG.height, 0x0);
add(canvas);
}
override public function update(elapsed:Float) {
super.update(elapsed);
FlxSpriteUtil.fill(canvas, 0x0); // clear canvas
var swipe:FlxSwipe = null;
var color:FlxColor = 0;
for (s in FlxG.swipes) {
swipe = s;
if (swipe.qualified)
color = 0xFF00E676; // green
else color = 0xFFF44336; // red
FlxSpriteUtil.drawPolygon(canvas, swipe.path.nodes, 0x0, { thickness: 5, color: color });
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment