Make MovieFlxState generic with fff functionality
This commit is contained in:
@@ -495,7 +495,7 @@
|
||||
{
|
||||
(set FlxG.mouse.visible true)
|
||||
(set isLoading false)
|
||||
(unless MovieFlxState.focused
|
||||
(unless (Reflect.field FlxG.state "focused")
|
||||
(pause))
|
||||
(set FlxG.autoPause true)
|
||||
(FlxG.state.remove bar true)
|
||||
|
@@ -3,6 +3,8 @@ package hollywoo_flixel;
|
||||
import flixel.FlxG;
|
||||
import flixel.FlxState;
|
||||
import kiss.Prelude;
|
||||
import haxe.Constraints;
|
||||
|
||||
@:build(kiss.Kiss.build())
|
||||
class MovieFlxState extends FlxState {}
|
||||
@:generic
|
||||
class MovieFlxState<MovieClass:FlxMovie & Constructible<FlxDirector->Void>> extends FlxState {}
|
||||
|
@@ -1,11 +1,29 @@
|
||||
(prop &mut :FlxDirector director)
|
||||
|
||||
(method :Dynamic callPrivate [:Dynamic obj :String method &rest :Array<Dynamic> args]
|
||||
(Reflect.callMethod obj (Reflect.field obj method) args))
|
||||
|
||||
(prop &mut :MovieClass movie)
|
||||
(method :MovieClass currentMovie []
|
||||
#{
|
||||
var c = movie;
|
||||
while (c.skipMovie != null)
|
||||
c = cast c.skipMovie;
|
||||
return c;
|
||||
}#)
|
||||
|
||||
(method &override :Void create []
|
||||
(set destroySubStates false)
|
||||
(super.create)
|
||||
(set director (new FlxDirector)))
|
||||
(set director (new FlxDirector))
|
||||
(set movie (new MovieClass director))
|
||||
(director.promptForResume movie))
|
||||
|
||||
(var &mut focused true)
|
||||
(method &override :Void destroy []
|
||||
(callPrivate (currentMovie) "doCleanup")
|
||||
(super.destroy))
|
||||
|
||||
(prop &mut focused true)
|
||||
|
||||
(method &override :Void onFocusLost []
|
||||
(when FlxG.autoPause
|
||||
@@ -16,4 +34,14 @@
|
||||
(when (and FlxG.autoPause !director.movie.paused)
|
||||
(director.resume))
|
||||
(kiss_flixel.DebugTools.f1ToRecord director.actionManager)
|
||||
(set focused true))
|
||||
(set focused true))
|
||||
|
||||
(method &override :Void update [:Float elapsed]
|
||||
#{
|
||||
super.update(elapsed);
|
||||
var c = currentMovie();
|
||||
if (c.running)
|
||||
{
|
||||
c.update(elapsed);
|
||||
}
|
||||
}#)
|
||||
|
Reference in New Issue
Block a user