Created
April 28, 2020 15:31
-
-
Save opensussex/da40091dbe9e2943425c29cbdf927042 to your computer and use it in GitHub Desktop.
basics of a play state with mouse interaction haxeflixel
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 flixel.FlxState; | |
import flixel.input.mouse.FlxMouseEventManager; | |
import flixel.input.mouse.FlxMouseButton.FlxMouseButtonID; | |
class PlayState extends FlxState | |
{ | |
var player:Player; | |
override public function create() | |
{ | |
super.create(); | |
FlxMouseEventManager.init(); | |
var text = new flixel.text.FlxText(0, 0, 0, "Hello World", 64); | |
text.screenCenter(); | |
player = new Player(20, 20); | |
add(player); | |
//add(text); | |
var pixelPerfect = false; | |
FlxMouseEventManager.add( | |
player, | |
mousePressedCallback, | |
mouseReleasedCallback, | |
null, | |
null, | |
false, | |
true, | |
pixelPerfect, | |
[FlxMouseButtonID.LEFT, FlxMouseButtonID.RIGHT] | |
); | |
} | |
override public function update(elapsed:Float) | |
{ | |
super.update(elapsed); | |
} | |
function mousePressedCallback(sprite:Player) | |
{ | |
trace('Pressed'); | |
} | |
function mouseReleasedCallback(sprite:Player) | |
{ | |
trace('Released'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment