This repository has been archived by the owner on Nov 14, 2024. It is now read-only.
generated from ShadowMario/FNF-PsychEngine
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6f63961
commit a4f2dac
Showing
6 changed files
with
95 additions
and
0 deletions.
There are no files selected for viewing
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Your SWF movies go here! | ||
Make sure they are in the .swf format (obviously)! |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
package; | ||
|
||
import openfl.utils.Assets; | ||
import flixel.system.FlxSound; | ||
import openfl.display.Sprite; | ||
import openfl.Lib; | ||
import openfl.events.Event; | ||
import flixel.FlxG; | ||
import openfl.display.MovieClip; | ||
|
||
class SwfVideo extends Sprite | ||
{ | ||
public var clip:MovieClip; | ||
|
||
private var barLeft:Sprite; | ||
private var barRight:Sprite; | ||
|
||
public function new(movieClip:String, sound:String, onComplete:Void->Void) | ||
{ | ||
super(); | ||
|
||
barLeft = new Sprite(); | ||
barRight = new Sprite(); | ||
|
||
var audio:FlxSound = new FlxSound().loadEmbedded(sound); | ||
Assets.loadLibrary('$movieClip').onComplete(function(_) { | ||
clip = Assets.getMovieClip('$movieClip:'); | ||
addChild(clip); | ||
|
||
addChild(barLeft); | ||
addChild(barRight); | ||
|
||
audio.onComplete = function() { | ||
onComplete(); | ||
removeChild(clip); | ||
(cast (Lib.current.getChildAt(0), Main)).removeChild(this); | ||
}; | ||
audio.play(); | ||
}); | ||
|
||
(cast (Lib.current.getChildAt(0), Main)).addChild(this); | ||
|
||
addEventListener(Event.ENTER_FRAME, onResize); | ||
} | ||
|
||
/** | ||
* Partly Copied from FlxGame | ||
*/ | ||
function onResize(_):Void | ||
{ | ||
var width:Int = FlxG.stage.stageWidth; | ||
var height:Int = FlxG.stage.stageHeight; | ||
|
||
width > height ? | ||
clip.scaleX = clip.scaleY = height / 720 | ||
: clip.scaleY = clip.scaleX = width / 1280; | ||
|
||
screenCenter(); | ||
|
||
// trace('RESIZED TO ${clip.scaleX}%'); | ||
} | ||
|
||
public function screenCenter() | ||
{ | ||
var ratio:Float = FlxG.width / FlxG.height; | ||
var realRatio:Float = FlxG.stage.stageWidth / FlxG.stage.stageHeight; | ||
var preX:Float = 0; | ||
|
||
preX = Math.floor(FlxG.stage.stageHeight * ratio); | ||
|
||
clip.x = Math.ceil((FlxG.stage.stageWidth - preX) * 0.5); | ||
|
||
barLeft.graphics.clear(); | ||
barRight.graphics.clear(); | ||
barLeft.graphics.beginFill(); | ||
barRight.graphics.beginFill(); | ||
barLeft.graphics.drawRect(0, 0, clip.x, FlxG.stage.stageHeight); | ||
barRight.graphics.drawRect(FlxG.stage.stageWidth - clip.x, 0, clip.x, FlxG.stage.stageHeight); | ||
} | ||
} |