31 lines
1.1 KiB
Plaintext
31 lines
1.1 KiB
Plaintext
(prop :FlxStageFacing defaultFacing)
|
|
|
|
(prop :FuzzyMap<String> animationNames (new FuzzyMap<String>))
|
|
|
|
(defNew [&prop :String assetPath &opt frameWidth frameHeight :FlxStageFacing defaultFacing :Map<String,AnimationArgs> animations]
|
|
(super)
|
|
|
|
(set this.defaultFacing (or defaultFacing Right))
|
|
|
|
(if (and frameWidth frameHeight)
|
|
(loadGraphic assetPath true frameWidth frameHeight)
|
|
(loadGraphic assetPath))
|
|
(when animations
|
|
(doFor =>name animationArgs animations
|
|
(dictSet animationNames name name)
|
|
(animation.add
|
|
name
|
|
animationArgs.frames
|
|
(or animationArgs.frameRate 30)
|
|
(or animationArgs.looped true)
|
|
?animationArgs.flipX
|
|
?animationArgs.flipY))))
|
|
|
|
(method :Void playAnimation [fuzzySearchKey]
|
|
(if (animationNames.exists fuzzySearchKey)
|
|
(animation.play (dictGet animationNames fuzzySearchKey) true)
|
|
(#when debug
|
|
(print "WARNING! No animation matches $fuzzySearchKey for actor with spritesheet $assetPath"))))
|
|
|
|
(method :Void stopAnimation []
|
|
(animation.stop)) |