optimize adding additional jigsaw sprites
This commit is contained in:
@@ -29,6 +29,19 @@ class DragToSelectPlugin extends FlxBasic {
|
||||
super();
|
||||
}
|
||||
|
||||
public function clearEnabledSprites(?state:FlxState) {
|
||||
if (state == null) state = FlxG.state;
|
||||
dragStates[state].enabledSprites = [];
|
||||
dragStates[state].selectedSprites = [];
|
||||
}
|
||||
|
||||
// Don't use this on a whole list of sprites! It will be O(N^2)
|
||||
public function disableSprite(s: KissExtendedSprite, ?state:FlxState) {
|
||||
if (state == null) state = FlxG.state;
|
||||
dragStates[state].enabledSprites.remove(s);
|
||||
dragStates[state].selectedSprites.remove(s);
|
||||
}
|
||||
|
||||
public function enableSprite(s:KissExtendedSprite, ?state:FlxState, ?camera:FlxCamera) {
|
||||
if (state == null) state = FlxG.state;
|
||||
if (camera == null) camera = FlxG.camera;
|
||||
|
@@ -115,8 +115,19 @@ class KissExtendedSprite extends flixel.addons.display.FlxExtendedSprite {
|
||||
plugin.enableSprite(this, state, thisCamera());
|
||||
_dragToSelectEnabled = true;
|
||||
}
|
||||
public function disableDragToSelect(?state:FlxState) {
|
||||
var plugin = FlxG.plugins.get(DragToSelectPlugin);
|
||||
plugin.disableSprite(this, state);
|
||||
_dragToSelectEnabled = false;
|
||||
}
|
||||
|
||||
override function update(elapsed:Float) {
|
||||
public override function destroy() {
|
||||
if (_dragToSelectEnabled)
|
||||
disableDragToSelect();
|
||||
super.destroy();
|
||||
}
|
||||
|
||||
public override function update(elapsed:Float) {
|
||||
#if debug
|
||||
// color = (mouseOver && pixelPerfect(_dragPixelPerfectAlpha)) ? FlxColor.LIME : FlxColor.WHITE;
|
||||
#end
|
||||
|
Reference in New Issue
Block a user