File tree Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -143,11 +143,18 @@ class AttractState extends FlxState
143143
144144 videoSprite = new FlxVideoSprite ();
145145 videoSprite .bitmap .onEndReached .add (() -> startNextVideo ());
146+ videoSprite .bitmap .onTextureSetup .add (() -> {
147+ var videoW = videoSprite .bitmap .bitmapData .width ;
148+ var videoH = videoSprite .bitmap .bitmapData .height ;
149+ var screenW = FlxG .width ;
150+ var screenH = FlxG .height ;
151+ var scale = Math .min (screenW / videoW , screenH / videoH );
152+ videoSprite .setGraphicSize (Std .int (videoW * scale ), Std .int (videoH * scale ));
153+ videoSprite .x = Std .int ((screenW - videoSprite .width ) / 2 );
154+ videoSprite .y = Std .int ((screenH - videoSprite .height ) / 2 );
155+ });
146156 videoSprite .play (path , false );
147157 videoSprite .bitmap .volume = Std .int (FlxG .sound .volume * 100 );
148- videoSprite .x = 0 ;
149- videoSprite .y = 0 ;
150- videoSprite .setGraphicSize (FlxG .width , FlxG .height );
151158 add (videoSprite ); // Add before overlays for correct layering
152159 }
153160
You can’t perform that action at this time.
0 commit comments