Pausable tweens
This commit is contained in:
@@ -34,18 +34,14 @@
|
||||
(doFor sound currentSounds
|
||||
(sound.pause))
|
||||
(when music
|
||||
(music.pause))
|
||||
// TODO tweens
|
||||
)
|
||||
(music.pause)))
|
||||
|
||||
(method :Void resume []
|
||||
(FlxG.inputs.add actionManager)
|
||||
(doFor sound currentSounds
|
||||
(sound.resume))
|
||||
(when music
|
||||
(music.resume))
|
||||
// TODO tweens
|
||||
)
|
||||
(music.resume)))
|
||||
|
||||
(method :Void showPauseMenu [:Continuation resume]
|
||||
// register escape to resume (and register escape to pause when resuming lol)
|
||||
@@ -440,8 +436,7 @@
|
||||
(method :Void hideBlackScreen []
|
||||
(FlxG.state.remove blackBG))
|
||||
|
||||
// TODO maybe credits need their own substate so an after-credits scene could be done.
|
||||
// currently the bg will cover whatever the final scene was.
|
||||
// TODO currently the bg will cover whatever the final scene was - making after credits scenes impossible
|
||||
(method :Void rollCredits [:Array<CreditsLine> credits cc]
|
||||
(localVar bg (new FlxSprite))
|
||||
(bg.makeGraphic FlxG.width FlxG.height FlxColor.BLACK true)
|
||||
@@ -489,4 +484,10 @@
|
||||
(doFor text creditsText
|
||||
(FlxG.state.add text)
|
||||
(set text.cameras [flxMovie.uiCamera])
|
||||
(FlxTween.linearMotion text text.x text.y text.x (- text.y textY) 200 false (object onComplete ->:Void _ (cc)))))
|
||||
(let [:Array<Dynamic> tweenArgs []]
|
||||
(tweenArgs.push text)
|
||||
(tweenArgs.push text.x)
|
||||
(tweenArgs.push (- text.y textY))
|
||||
(tweenArgs.push 200)
|
||||
(tweenArgs.push cc)
|
||||
(Reflect.callMethod flxMovie (Reflect.field flxMovie "linearMotion") tweenArgs))))
|
@@ -11,6 +11,7 @@ import hollywoo_flixel.ActorFlxSprite;
|
||||
import kiss_flixel.SpriteTools;
|
||||
import kiss_tools.FlxKeyShortcutHandler;
|
||||
import openfl.Assets;
|
||||
import flixel.tweens.FlxTween;
|
||||
|
||||
/**
|
||||
* Model/controller of a Hollywoo-Flixel film, and main execution script
|
||||
@@ -28,6 +29,8 @@ class FlxMovie extends Movie<FlxSprite, ActorFlxSprite, FlxSound, String, FlxSpr
|
||||
}
|
||||
public var uiCamera:FlxCamera;
|
||||
public var screenCamera:FlxCamera;
|
||||
|
||||
public var tweens:Array<FlxTween> = [];
|
||||
|
||||
public var STAGE_LEFT_X:Float;
|
||||
public var STAGE_RIGHT_X:Float;
|
||||
|
@@ -4,6 +4,25 @@
|
||||
(loadFrom "hollywoo" "src/hollywoo/Movie.kiss")
|
||||
(loadFrom "hollywoo-flixel" "src/hollywoo_flixel/Aliases.kiss")
|
||||
|
||||
(method :Dynamic callPrivate [:Dynamic obj :String method &rest :Array<Dynamic> args]
|
||||
(Reflect.callMethod obj (Reflect.field obj method) args))
|
||||
|
||||
(method tween [:FlxTween tween]
|
||||
(callPrivate FlxTween.globalManager "remove" tween false)
|
||||
(tweens.push tween))
|
||||
(method :TweenOptions tweenOpts [&opt :Void->Void cc]
|
||||
(object
|
||||
onComplete
|
||||
->:Void tween {
|
||||
(tweens.remove tween)
|
||||
(when cc (cc))
|
||||
}))
|
||||
|
||||
(method linearMotion [:FlxSprite sprite :Float destX :Float destY :Float speed &opt :Void->Void cc]
|
||||
(tween
|
||||
(FlxTween.linearMotion sprite sprite.x sprite.y destX destY speed false (tweenOpts cc))))
|
||||
(defAlias &ident FlxTween.linearMotion CHANGE_TO_MOVIE_LINEARMOTION)
|
||||
|
||||
(method newFlxSet [name assetPath]
|
||||
(let [setSprite (new FlxSprite 0 0)]
|
||||
(setSprite.loadGraphic assetPath false 0 0 true) // Load uniquely so we can draw on sets for specific scenes
|
||||
@@ -39,6 +58,9 @@
|
||||
`(new FlxSprite 0 0 ,(b.field (symbolNameValue asset) (b.symbol "AssetPaths"))))
|
||||
|
||||
(method :Void update [:Float elapsed]
|
||||
(unless paused
|
||||
(doFor tween tweens
|
||||
(callPrivate tween "update" elapsed )))
|
||||
(.update (cast (director.shortcutHandler) kiss_tools.FlxKeyShortcutHandler<Dynamic>)))
|
||||
|
||||
(defAlias &ident flxDirector (cast director FlxDirector))
|
||||
|
Reference in New Issue
Block a user