protected override void Create() { base.Create(); closeBtn = new FlxButton(FlxG.Width * 0.5f - 40f, FlxG.Height * 0.5f, "Close", OnClick); Add(closeBtn); switchParentDrawingBtn = new FlxButton(closeBtn.X, closeBtn.Y + 40, "SwitchDraw", OnSwitchDraw); Add(switchParentDrawingBtn); switchParentUpdatingBtn = new FlxButton(switchParentDrawingBtn.X, switchParentDrawingBtn.Y + 40, "SwitchUpdate", OnSwitchUpdate); Add(switchParentUpdatingBtn); testSprite = new FlxSprite(0, 10); testSprite.Velocity.X = 20; Add(testSprite); }
protected override void Create() { FlxG.Cameras.BgColor = Color.White; DestroySubStates = false; // Some test group of sprites, used for showing substate system features sprites = new MySpriteGroup(50); Add(sprites); subStateColor = new Color(128, 128, 128, 153); // We can create persistent substate and use it as many times as we want persistentSubState = new SubState(subStateColor); persistentSubState.isPersistent = true; openpersistentBtn = new FlxButton(20, 20, "OpenPersistent", OnpersistentClick); Add(openpersistentBtn); openTempBtn = new FlxButton(20, 60, "OpenTemp", OnTempClick); Add(openTempBtn); base.Create(); }
override public void create() { base.create(); // play some music FlxG.playMp3("Lemonade/music/music_menu_1", 0.75f); // load some tile maps List <Dictionary <string, string> > bgString = FlxXMLReader.readNodesFromTmxFile("Lemonade/levels/slf2/newyork/bgnewyork.tmx", "map", "bg", FlxXMLReader.TILES); ny = new FlxTilemap(); ny.auto = FlxTilemap.STRING; ny.indexOffset = -1; ny.loadMap(bgString[0]["csvData"], FlxG.Content.Load <Texture2D>("Lemonade/bgtiles_newyork"), 20, 20); ny.boundingBoxOverride = true; ny.setScrollFactors(0, 0); ny.visible = false; add(ny); bgString = FlxXMLReader.readNodesFromTmxFile("Lemonade/levels/slf2/sydney/bgsydney.tmx", "map", "bg", FlxXMLReader.TILES); sydney = new FlxTilemap(); sydney.auto = FlxTilemap.STRING; sydney.indexOffset = -1; sydney.loadMap(bgString[0]["csvData"], FlxG.Content.Load <Texture2D>("Lemonade/bgtiles_sydney"), 20, 20); sydney.boundingBoxOverride = true; sydney.setScrollFactors(0, 0); sydney.visible = false; add(sydney); bgString = FlxXMLReader.readNodesFromTmxFile("Lemonade/levels/slf2/military/bgmilitary.tmx", "map", "bg", FlxXMLReader.TILES); miltary = new FlxTilemap(); miltary.auto = FlxTilemap.STRING; miltary.indexOffset = -1; miltary.loadMap(bgString[0]["csvData"], FlxG.Content.Load <Texture2D>("Lemonade/bgtiles_military"), 20, 20); miltary.boundingBoxOverride = true; miltary.setScrollFactors(0, 0); miltary.visible = false; add(miltary); //FlxG.mouse.show(FlxG.Content.Load<Texture2D>("Mode/cursor")); FlxButton b = new FlxButton((FlxG.width / 2) - 100, 150, startGame); b.loadGraphic(new FlxSprite().loadGraphic(FlxG.Content.Load <Texture2D>("Lemonade/button_ny")), new FlxSprite().loadGraphic(FlxG.Content.Load <Texture2D>("Lemonade/buttonPressed_ny"))); b.loadText(new FlxText(-20, 10, 100, "Sydney"), new FlxText(-20, 10, 100, "Sydney!")); buttons.add(b); b = new FlxButton(FlxG.width / 2, 150, startGame); b.loadGraphic(new FlxSprite().loadGraphic(FlxG.Content.Load <Texture2D>("Lemonade/button_ny")), new FlxSprite().loadGraphic(FlxG.Content.Load <Texture2D>("Lemonade/buttonPressed_ny"))); b.loadText(new FlxText(-20, 10, 100, "New York"), new FlxText(-20, 10, 100, "New York!")); buttons.add(b); b = new FlxButton((FlxG.width / 2) + 100, 150, startGame); b.loadGraphic(new FlxSprite().loadGraphic(FlxG.Content.Load <Texture2D>("Lemonade/button_ny")), new FlxSprite().loadGraphic(FlxG.Content.Load <Texture2D>("Lemonade/buttonPressed_ny"))); b.loadText(new FlxText(-20, 10, 100, "Military"), new FlxText(-20, 10, 100, "Military!")); buttons.add(b); for (int i = 1; i < 13; i++) { FlxButton a = new FlxButton(175 + (i * 45), 225, startGame); a.loadGraphic(new FlxSprite().loadGraphic(FlxG.Content.Load <Texture2D>("Lemonade/button_ny")), new FlxSprite().loadGraphic(FlxG.Content.Load <Texture2D>("Lemonade/buttonPressed_ny"))); a.loadText(new FlxText(-40, 10, 100, i.ToString()), new FlxText(-40, 10, 100, i.ToString() + "!")); buttons.add(a); } b = new FlxButton((FlxG.width / 2) - 100, 275, startMultiplayerGame); b.loadGraphic(new FlxSprite().loadGraphic(FlxG.Content.Load <Texture2D>("Lemonade/button_ny")), new FlxSprite().loadGraphic(FlxG.Content.Load <Texture2D>("Lemonade/buttonPressed_ny"))); b.loadText(new FlxText(-20, 10, 100, "Multiplayer"), new FlxText(-20, 10, 100, "Multiplayer!")); buttons.add(b); location = new FlxText(0, 50, FlxG.width); location.setFormat(FlxG.Content.Load <SpriteFont>("Lemonade/SMALL_PIXEL"), 3, Color.White, FlxJustification.Center, Color.Black); location.text = ""; add(location); addButtons(); FlxText badges = new FlxText(0, 330, 0, "Badges"); badges.setFormat(FlxG.Content.Load <SpriteFont>("Lemonade/SMALL_PIXEL"), 3, Color.White, FlxJustification.Left, Color.Black); add(badges); Color notDone = new Color(0.1f, 0.1f, 0.1f); badge1 = new FlxSprite((FlxG.width / 2) - 150, 330); badge1.loadGraphic(FlxG.Content.Load <Texture2D>("Lemonade/offscreenIcons"), true, false, 12, 12); badge1.frame = 2; badge1.color = notDone; add(badge1); badge2 = new FlxSprite((FlxG.width / 2) - 50, 330); badge2.loadGraphic(FlxG.Content.Load <Texture2D>("Lemonade/offscreenIcons"), true, false, 12, 12); badge2.frame = 3; badge2.color = notDone; add(badge2); badge3 = new FlxSprite((FlxG.width / 2) + 50, 330); badge3.loadGraphic(FlxG.Content.Load <Texture2D>("Lemonade/offscreenIcons"), true, false, 12, 12); badge3.frame = 4; badge3.color = notDone; add(badge3); badge4 = new FlxSprite((FlxG.width / 2) + 150, 330); badge4.loadGraphic(FlxG.Content.Load <Texture2D>("Lemonade/offscreenIcons"), true, false, 12, 12); badge4.frame = 5; badge4.color = notDone; add(badge4); tweenBounce = new Tweener(5.0f, 8.0f, TimeSpan.FromSeconds(1.12f), Elastic.EaseOut); tweenBounce.PingPong = true; try { FlxG.username = LoadFromDevice(); } catch { Console.WriteLine("Cannot load name from file"); } if (FlxG.username != "") { //_nameEntry.text = FlxG.username; FlxG.setHudText(3, "Username:\n" + FlxG.username); FlxG.setHudTextPosition(3, 50, FlxG.height - 30); FlxG.setHudTextScale(3, 2); } }