package { import flash.display.Sprite; import flash.events.Event; import…
- User
package { import flash.display.Sprite; import flash.events.Event; import launcher.background.Background_Main; import launcher.button.FightButton; import launcher.panel.social.socialPanel; import launcher.snow.Snow; import flash.display.StageAlign; import flash.display.StageDisplayState; import flash.display.StageQuality; import flash.display.StageScaleMode; import flash.display.NativeWindow; import flash.geom.Point; import flash.geom.Rectangle; import flash.display.Screen; import zip.ZIPResourceLoader;
/** * ... * @author alekskart */ public class Main extends Sprite { private var guiLayer:Sprite; public var background:Background_Main = new Background_Main(); public var progressBar:ProgressBar; public var socialbar:socialPanel = new socialPanel(); public var fightButton:FightButton = new FightButton(); public var bgButton:bg_button = new bg_button(); public function Main() { if (stage) init(); else addEventListener(Event.ADDED_TO_STAGE, init); //var ziploader:ZIPResourceLoader = new ZIPResourceLoader(progressBar); } private function init(e:Event = null):void { removeEventListener(Event.ADDED_TO_STAGE, init); this.configureStage(); this.createGUI(); } private function setCenterPosition() : void { var appBounds:Rectangle = stage.nativeWindow.bounds; var screen:Screen = Screen.getScreensForRectangle(appBounds)[0]; stage.stageWidth = 1024; stage.stageHeight = 670; stage.nativeWindow.maxSize = new Point(stage.nativeWindow.width,stage.nativeWindow.height); stage.nativeWindow.minSize = new Point(stage.nativeWindow.width,stage.nativeWindow.height); stage.nativeWindow.x = (screen.bounds.width - stage.nativeWindow.width) / 2; stage.nativeWindow.y = (screen.bounds.height - stage.nativeWindow.height) / 2; } private function configureStage() : void { stage.align = StageAlign.TOP_LEFT; stage.scaleMode = StageScaleMode.NO_SCALE; stage.quality = StageQuality.BEST; stage.displayState = StageDisplayState.NORMAL; stage.stageWidth = 1024; stage.stageHeight = 670; this.setCenterPosition(); } private function createGUI() : void { this.guiLayer = new Sprite(); this.background.width = stage.stageWidth; // установите ширину картинки равной ширине окна this.background.height = stage.stageHeight; // установите высоту картинки равной высоте окна this.background.y = 0; this.guiLayer.addChild(this.background); this.socialbar.x = stage.stageWidth - this.socialbar.width - 15; this.socialbar.y = 29; this.guiLayer.addChild(this.socialbar); this.fightButton.x = stage.stageWidth / 2 - this.fightButton.width / 2; this.fightButton.y = stage.stageHeight / 2 - this.fightButton.height / 2 + 185; this.guiLayer.addChild(this.fightButton); this.progressBar = new ProgressBar(); this.guiLayer.addChild(this.progressBar); this.guiLayer.addChild(new Snow(25)); addChild(this.guiLayer); stage.addEventListener(Event.RESIZE, onResize); } private function onResize(event:Event):void { var scale:Number = Math.min(stage.stageWidth / this.background.width, stage.stageHeight / this.background.height); this.background.width *= scale; this.background.height *= scale; // Уменьшение высоты картинки var newHeight:Number = this.background.height * 0.86; // Новая высота (80% от текущей) this.background.height = newHeight; // Центрирование картинки background по середине окна this.background.x = (stage.stageWidth - this.background.width) / 2; // this.background.y = (stage.stageHeight - this.background.height) * 0.25; // Новая позиция по оси Y (25% от верхней границы окна) } } - Assistant
Чтобы bgButton был расположен позади fightButton, вы можете изменить порядок добавления их в родительский контейнер. Вместо добавления fightButton сразу после socialbar, вы можете добавить bgButton первым, а затем добавить fightButton. Вот как будет выглядеть измененный код:
private function createGUI() : void { this.guiLayer = new Sprite(); // Добавить bgButton перед socialbar this.bgButton.x = stage.stageWidth / 2 - this.bgButton.width / 2; this.bgButton.y = stage.stageHeight / 2 - this.bgButton.height / 2; this.guiLayer.addChild(this.bgButton); this.background.width = stage.stageWidth; // установите ширину картинки равной ширине окна this.background.height = stage.stageHeight; // установите высоту картинки равной высоте окна this.background.y = 0; this.guiLayer.addChild(this.background); this.socialbar.x = stage.stageWidth - this.socialbar.width - 15; this.socialbar.y = 29; this.guiLayer.addChild(this.socialbar); // Добавить fightButton после bgButton this.fightButton.x = stage.stageWidth / 2 - this.fightButton.width / 2; this.fightButton.y = stage.stageHeight / 2 - this.fightButton.height / 2 + 185; this.guiLayer.addChild(this.fightButton); this.progressBar = new ProgressBar(); this.guiLayer.addChild(this.progressBar); this.guiLayer.addChild(new Snow(25)); addChild(this.guiLayer); stage.addEventListener(Event.RESIZE, onResize); }
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.