public override void create() { _timer = 0; _fading = false; FlxG.flash(Color.White); //Gibs emitted upon death FlxEmitter gibs = new FlxEmitter(0, -50); gibs.setSize((uint)FlxG.width, 0); gibs.setXSpeed(); gibs.setYSpeed(0, 100); gibs.setRotation(-360, 360); gibs.gravity = 80; gibs.makeParticles(ImgGibs, 800, 32, true, 0); add(gibs); gibs.start(false, 0, 0.005f); FlxText text = new FlxText(0, FlxG.height / 2 - 35, FlxG.width, "VICTORY\n\nSCORE: " + FlxG.score); /* * if(Gdx.app.getType() == ApplicationType.WebGL) * text.setFormat(ImgFont20,20,0xd8eba2,"center"); * else * text.setFormat(null,16,0xd8eba2,"center");*/ add(text); }
/// <summary> /// Plant that can lose leaves /// </summary> /// <param name="xPos"></param> /// <param name="yPos"></param> /// <param name="type">Two types of plants. 1 and 2.</param> public Plant(int xPos, int yPos, int type) : base(xPos, yPos) { if (type == 1) { loadGraphic(FlxG.Content.Load <Texture2D>("Lemonade/plant1"), false, false, 10, 110); } else if (type == 2) { loadGraphic(FlxG.Content.Load <Texture2D>("Lemonade/plant2"), false, false, 13, 110); } _leaves = new FlxEmitter(); _leaves.setSize(2, 110); _leaves.createSprites(FlxG.Content.Load <Texture2D>("Lemonade/leaves"), 30, true, 0.0f, 0.0f); _leaves.setRotation(0, 360); _leaves.setYSpeed(15, 85); _leaves.setXSpeed(-40, 40); _leaves.gravity = 15; _leaves.at(this); canLoseLeaves = 110; }
override public void create() { base.create(); FlxG.setHudGamepadButton(FlxHud.TYPE_KEYBOARD, FlxHud.Keyboard_Arrow_Left, 10, 110); FlxG.setHudGamepadButton(FlxHud.TYPE_KEYBOARD_DIRECTION, FlxHud.Keyboard_Arrow_Right, 110, 110); FlxSprite bg = new FlxSprite(0, 0); bg.createGraphic(FlxG.width, FlxG.width, new Color(0.05f, 0.05f, 0.08f)); bg.setScrollFactors(0, 0); add(bg); stars = new FlxGroup(); // Make a starfield to fly through. for (int i = 0; i < 100; i++) { star = new FlxSprite(FlxU.random(0, FlxG.width), FlxU.random(0, FlxG.height)); star.createGraphic(3, 3, Color.White); star.velocity.Y = FlxU.random(20, 100); star.velocity.X = 0; stars.add(star); } add(stars); spaceShip = new FlxSprite(FlxG.width / 2, FlxG.height / 2); spaceShip.loadGraphic(FlxG.Content.Load <Texture2D>("flixel/surt/spaceship_32x32"), true, false, 32, 32); //Add some animations to our Spaceship spaceShip.addAnimation("static", new int[] { 0 }, 36, true); spaceShip.addAnimation("transform1", new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19 }, 12, false); spaceShip.addAnimation("transform2", new int[] { 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39 }, 12, false); spaceShip.addAnimation("transform3", new int[] { 40, 41, 42 }, 12, false); //spaceShip.addAnimation("transform", new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39}, 24, false); //spaceShip.addAnimation("reverse", new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39 }, 24, false); spaceShip.addAnimation("transform", spaceShip.generateFrameNumbersBetween(0, 39), 24, false); spaceShip.addAnimation("reverse", spaceShip.generateFrameNumbersBetween(39, 0), 24, false); spaceShip.play("static"); //Add an animation callback - This will call Pulse on every frame. spaceShip.addAnimationCallback(pulse); spaceShip.scale = 3; spaceShip.setDrags(1100, 1100); add(spaceShip); jets = new FlxEmitter(); jets.setSize(5, 50); jets.createSprites(FlxG.Content.Load <Texture2D>("flixel/diagnostic/testpalette"), 100, true, 0.0f, 0.0f); jets.setXSpeed(-110, 110); jets.setYSpeed(40, 80); add(jets); jets.at(spaceShip); }
/*private FlxVirtualPad _pad;*/ public override void create() { FlxG.width = (int)FlxG.camera.Width;// ViewportWidth; FlxG.resetCameras(); FlxG.bgColor = Color.Black; //Simple use of flixel save game object. //Tracks number of times the game has been played. /*FlxSave save = new FlxSave(); if(save.bind("Mode")) { if(save.data.get("plays", Integer.class) == null) save.data.put("plays", 0); else save.data.put("plays", save.data.get("plays", Integer.class) + 1); FlxG.log("Number of plays: "+save.data.get("plays", Integer.class)); //save.erase(); save.close(); } */ //All the bits that blow up when the text smooshes together gibs = new FlxEmitter(FlxG.width/2-50,FlxG.height/2-10); gibs.setSize(100,30); gibs.setYSpeed(-200,-20); gibs.setRotation(-720,720); gibs.gravity = 100; gibs.makeParticles(ImgGibs,650,32,true,0); add(gibs); //the letters "mo" title1 = new FlxText(FlxG.width + 16,FlxG.height/3,64,"mo"); /* if(Gdx.app.getType() == ApplicationType.WebGL) title1.setFormat(ImgFont40, 40); else title1.SetSize(32); title1.SetColor(0x3a5c39); title1.Antialiasing = true; */ title1.Velocity.X = -FlxG.width; title1.Moves = true; add(title1); //the letters "de" title2 = new FlxText(-60,title1.Y,(int) title1.Width,"de"); /* if(Gdx.app.getType() == ApplicationType.WebGL) title2.setFormat(ImgFont40, 40); else title2.SetSize(32); title2.SetColor(title1.GetColor()); title2.Antialiasing = title1.Antialiasing; */ title2.Velocity.X = FlxG.width; title2.Moves = true; add(title2); fading = false; timer = 0; attractMode = false; //FlxG.mouse.show(FlxS.ContentManager.Load<Texture2D>(ImgCursor),2); /* _pad = new FlxVirtualPad(FlxVirtualPad.DPAD_None, FlxVirtualPad.A_B); _pad.setAlpha(0.5f); if(Gdx.app.getType() != ApplicationType.Desktop) add(_pad); */ }
override public void create() { base.create(); Lemonade_Globals.coinsThisLevel = 0; Console.WriteLine("Starting Level {0} : {1}", FlxG.level, Lemonade_Globals.location); FlxG.transition.resetAndStop(); FlxG._game.hud.p1HudText.x = -1000; FlxG._game.hud.p2HudText.x = -1000; FlxG._game.hud.p3HudText.x = -1000; FlxG._game.hud.p4HudText.x = -1000; FlxG._game.hud.setHudGamepadButton(FlxHud.TYPE_KEYBOARD, 0, -1000, -1000); FlxG.mouse.hide(); FlxG.autoHandlePause = true; actors = new FlxGroup(); trampolines = new FlxGroup(); levelItems = new FlxGroup(); ramps = new FlxGroup(); smallCrates = new FlxGroup(); movingPlatforms = new FlxGroup(); hazards = new FlxGroup(); collidableTileblocks = new FlxGroup(); coins = new FlxGroup(); //Level Adjust buildTileset(); buildActors(); buildBoxes(); add(trampolines); add(levelItems); add(ramps); add(smallCrates); add(movingPlatforms); add(actors); add(collidableTileblocks); add(hazards); add(coins); //set up a little bubble particle system. bubbleParticle = new FlxEmitter(); bubbleParticle.delay = 3; bubbleParticle.setXSpeed(-150, 150); bubbleParticle.setYSpeed(-40, 100); bubbleParticle.setRotation(-720, 720); bubbleParticle.gravity = Lemonade_Globals.GRAVITY * -0.25f; bubbleParticle.createSprites(FlxG.Content.Load <Texture2D>("Lemonade/bubble"), 200, true, 1.0f, 0.65f); add(bubbleParticle); crateParticle = new FlxEmitter(); crateParticle.delay = float.MaxValue; crateParticle.setSize(80, 60); crateParticle.setXSpeed(-350, 350); crateParticle.setYSpeed(-200, 200); crateParticle.setRotation(-720, 720); crateParticle.gravity = Lemonade_Globals.GRAVITY; crateParticle.createSprites(FlxG.Content.Load <Texture2D>("Lemonade/crateShards"), 200, true, 1.0f, 0.65f); add(crateParticle); // follow. FlxG.followBounds(0, 0, FlxG.levelWidth, FlxG.levelHeight); if (Lemonade_Globals.location == "factory") { FlxG.follow(worker, LERP); } if (Lemonade_Globals.location == "management") { FlxG.follow(liselot, LERP); } if (Lemonade_Globals.location == "military") { FlxG.follow(army, LERP); } if (Lemonade_Globals.location == "newyork") { FlxG.follow(chef, LERP); } if (Lemonade_Globals.location == "warehouse") { FlxG.follow(andre, LERP); } if (Lemonade_Globals.location == "sydney") { FlxG.follow(inspector, LERP); } playSong(); currentCharHud = new Hud(5, 5); add(currentCharHud); levelIntro = new LevelIntro(); add(levelIntro); currentCharHud.time = Lemonade_Globals.timeLeft; foreach (FlxSprite item in actors.members) { if (Lemonade_Globals.stateSaver[Lemonade_Globals.location].ContainsKey(item.ToString())) { try { item.x = Lemonade_Globals.stateSaver[Lemonade_Globals.location][item.ToString()].X; item.y = Lemonade_Globals.stateSaver[Lemonade_Globals.location][item.ToString()].Y; } catch (Exception) { Console.WriteLine("State saver not working for actors."); } } } int count = 0; foreach (FlxSprite item in coins.members) { if (Lemonade_Globals.stateSaver[Lemonade_Globals.location].ContainsKey(item.ToString() + count.ToString())) { try { //Lemonade_Globals.stateSaver[Lemonade_Globals.location][item.ToString() + count.ToString()] = new Vector2(item.x, item.y); if (item.ToString().StartsWith("Lemonade.Coin")) { //item.x = Lemonade_Globals.stateSaver[Lemonade_Globals.location][item.ToString() + count.ToString()].X; //item.y = Lemonade_Globals.stateSaver[Lemonade_Globals.location][item.ToString() + count.ToString()].Y; item.dead = Convert.ToBoolean(Lemonade_Globals.stateSaver[Lemonade_Globals.location][item.ToString() + count.ToString()].X); if (Convert.ToBoolean(Lemonade_Globals.stateSaver[Lemonade_Globals.location][item.ToString() + count.ToString()].X)) { item.x = -100; item.y = -100; } } count++; } catch (Exception) { Console.WriteLine("State saver not working for coins"); } } } }