Hello to all flashpunkers i’m develop new game with FP but i have some troubles and i hope you can save me i think use this post for all question if you agree
First problem: I’m making a game for PC (i think in future for OUYA and Iphone 5) with a support for full screen and window mode, i make an button for switch this mode but i have problems with this buttons you can try this (with an options screens) : https://mega.co.nz/#!ZMBBwI4D!UJTlrEJBqlt_s04TrsJtQgCfGIJqZtRZbOxuO4iT5k0
and this is a code:
package classes.Interface
{ import classes.; import classes.Schermate.MainMenu; import net.flashpunk.; import net.flashpunk.graphics.; import flash.display.;
/**
* ...
* @author Federico Fausto Santoro
*/
public class optionsWindow extends Entity
{
private var boxmain:Image;
private var bitFont:BitmapFont;
private var title:BitmapText;
private var btnVideo:Button;
private var btnAudio:Button;
private var btnLingua:Button;
private var btnData:Button;
private var btnBack:Button;
public var btnSave:Button;
//video
private var btnGraphicDown:Button_Diagonal;
private var btnGraphicUp:Button_Diagonal;
private var graphicLevel:OptionBar;
private var antialiasingCheck:CheckBox;
private var windowModeBTN:BigButtonBlu;
private var fullscreenBTN:BigButtonBlu;
private var antialiasingText:Text;
public function optionsWindow(xpos:uint, ypos:uint)
{
name = "mainWindowOptions";
super(xpos, ypos);
boxmain = Assets.getInterfaceElements("OPTIONS_MAIN_BOX");
bitFont = new BitmapFont(Assets.FONT_BITMAP_24, 24, 24);
title = new BitmapText(bitFont, "" + Lang.dizionario['options'], 'center', -10);
graphic = new Graphiclist(boxmain, title);
title.x += (boxmain.width / 2 - title.width / 2);
title.y += 6;
btnVideo = new Button(this.x, this.y, " "+Lang.dizionario['videooptions']+" ", null, false, 16, false, VideoOptions);
btnVideo.x += (boxmain.width / 2 - btnVideo.width / 2);
btnVideo.y += 50;
btnAudio = new Button(btnVideo.x, btnVideo.y, " "+Lang.dizionario['audiooptions']+" ", null, false, 16, false, null);
btnAudio.y += btnAudio.height + 10;
btnLingua = new Button(btnAudio.x, btnAudio.y, " "+Lang.dizionario['langoptions']+" ", null, false, 16, false, null);
btnLingua.y += btnLingua.height + 10;
btnData = new Button(btnLingua.x, btnLingua.y, " "+Lang.dizionario['dataoptions']+" ", null, false, 16, false, null);
btnData.y += btnData.height + 10;
btnSave = new Button(this.x, this.y, " " + Lang.dizionario['save'] + " ", null, false, 12, false, null);
btnSave.x += (boxmain.width / 2 - btnSave.width / 2);
btnSave.y += boxmain.height - btnSave.height / 2;
btnBack = new Button(this.x, this.y, " " + Lang.dizionario['back'] + " ", null, false, 12, false, null);
btnBack.x += (boxmain.width / 2 - btnBack.width / 2);
btnBack.y += boxmain.height - btnBack.height / 2;
//video
var qual:Number;
if (GLOBALS.qualita == "HIGH") qual = 3;
else if (GLOBALS.qualita == "MEDIUM") qual = 2;
else qual = 1;
windowModeBTN = new BigButtonBlu(this.x + 28, this.y + 60, !GLOBALS.fullscreen, Lang.dizionario['windowmode'], Assets.getAsset("ICON_WINDOWMODE"),gotoWindowMode);
fullscreenBTN = new BigButtonBlu(windowModeBTN.x + windowModeBTN.width + 10, windowModeBTN.y, GLOBALS.fullscreen, Lang.dizionario['fullscreenmode'], Assets.getAsset("ICON_FULLSCREENMODE"),gotoFullscreenMode);
graphicLevel = new OptionBar(this.x , windowModeBTN.y + windowModeBTN.height + 50, 3,1,Lang.dizionario['graphicquality'],qual);
graphicLevel.x += boxmain.width / 2 - graphicLevel.barContainer.width / 2;
btnGraphicDown = new Button_Diagonal(graphicLevel.x-30, graphicLevel.y, false, "-",decreaseGraphic);
btnGraphicUp = new Button_Diagonal(graphicLevel.x + graphicLevel.barContainer.width - 20, graphicLevel.y, true, "+",increaseGraphic);
antialiasingCheck = new CheckBox(btnGraphicDown.x, btnGraphicDown.y + 70,Lang.dizionario['antialiasing'], false);
}
//funzioni della schermata opzioni
public function remove():void {
this.world.removeList(this, btnAudio, btnData, btnLingua, btnSave, btnVideo);
}
public function add():void {
FP.world.addList(this, btnAudio, btnData, btnLingua, btnSave, btnVideo);
}
//cambio schermata
public function VideoOptions():void {
this.world.removeList( btnAudio, btnData, btnLingua, btnSave, btnVideo);
title.text = " " + Lang.dizionario['videooptions'] + " ";
this.world.addList(btnBack,graphicLevel,btnGraphicDown,btnGraphicUp,antialiasingCheck,windowModeBTN,fullscreenBTN);
btnBack.setCallback(function():void {
this.world.addList(btnAudio, btnData, btnLingua, btnSave, btnVideo);
this.world.removeList(btnBack,graphicLevel,btnGraphicDown,btnGraphicUp,antialiasingCheck,windowModeBTN,fullscreenBTN);
title.text = Lang.dizionario['options'];
} );
}
private function decreaseGraphic():void {
if (GLOBALS.qualita == "HIGH") {
GLOBALS.qualita = "MEDIUM";
FP.stage.quality = GLOBALS.qualita;
graphicLevel.changeVal(2);
}
else if (GLOBALS.qualita == "MEDIUM") {
GLOBALS.qualita = "LOW";
FP.stage.quality = GLOBALS.qualita;
graphicLevel.changeVal(1);
}
}
private function increaseGraphic():void {
if (GLOBALS.qualita == "LOW") {
GLOBALS.qualita = "MEDIUM";
FP.stage.quality = GLOBALS.qualita;
graphicLevel.changeVal(2);
}
else if(GLOBALS.qualita == "MEDIUM") {
GLOBALS.qualita = "HIGH";
FP.stage.quality = GLOBALS.qualita;
graphicLevel.changeVal(3);
}
}
private function changeWindowMode():void {
if (GLOBALS.fullscreen) {
fullscreenBTN.activeButton();
windowModeBTN.deactiveButton();
FP.stage.displayState = StageDisplayState.FULL_SCREEN_INTERACTIVE;
}
else {
fullscreenBTN.deactiveButton();
windowModeBTN.activeButton();
FP.stage.displayState = StageDisplayState.NORMAL;
}
GLOBALS.fullscreen = !GLOBALS.fullscreen;
trace("Fullscreen? " + GLOBALS.fullscreen);
}
private function gotoWindowMode():void {
GLOBALS.fullscreen = false;
fullscreenBTN.deactiveButton();
windowModeBTN.activeButton();
if (!GLOBALS.fullscreen) {
FP.stage.displayState = StageDisplayState.NORMAL;
}
trace("Fullscreen? w" + GLOBALS.fullscreen);
}
private function gotoFullscreenMode():void {
GLOBALS.fullscreen = true;
fullscreenBTN.activeButton();
windowModeBTN.deactiveButton();
if (GLOBALS.fullscreen) {
FP.stage.displayState = StageDisplayState.FULL_SCREEN_INTERACTIVE;
}
trace("Fullscreen? f" + GLOBALS.fullscreen);
}
//funzioni per la gestione delle opzioni
}
}