Skip to content

Commit c2db879

Browse files
committed
trying to fix trailers
1 parent e6e7875 commit c2db879

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

source/AttractState.hx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)