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); }
public Hud(int xPos, int yPos) : base(xPos, yPos) { loadGraphic(FlxG.Content.Load <Texture2D>("Lemonade/currentChar"), true, false, 14, 28); setScrollFactors(0, 0); addAnimation("andre", new int[] { 2 }, 0, true); play("andre"); coin = new Coin(FlxG.width - 24, 2, true); coin.setScrollFactors(0, 0); coinCounter = new FlxText(FlxG.width - 36, 10, 100); coinCounter.setFormat(null, 1, Lemonade_Globals.GAMEBOY_COLOR_4, FlxJustification.Left, Lemonade_Globals.GAMEBOY_COLOR_1); coinCounter.alignment = FlxJustification.Left; coinCounter.setScrollFactors(0, 0); toastySprite = new FlxSprite(0, FlxG.height); string person = "Lemonade/illustration/andre_drawing"; int ran = (int)FlxU.random(0, 4); switch (ran) { case 0: person = "Lemonade/illustration/andre_drawing"; break; case 1: person = "Lemonade/illustration/liselot_drawing"; break; case 2: person = "Lemonade/illustration/army_drawing"; break; case 3: person = "Lemonade/illustration/worker_drawing"; break; default: person = "Lemonade/illustration/andre_drawing"; break; } toastySprite.loadGraphic(person, false, false, 302, 640); toastySprite.setScrollFactors(0, 0); tween = new Tweener(4, 12, 1, Quadratic.EaseInOut); tween.Start(); tween.PingPong = true; powerBar = new FlxGroup(); for (int i = 0; i < 30; i++) { int offsetY = 0; int offsetS = 0; #if __ANDROID__ offsetY = 50; offsetS = 150; #endif FlxSprite bar = new FlxSprite(offsetS + 5 + (i * 10), FlxG.height - 10 - offsetY); bar.createGraphic(8, 8, Lemonade_Globals.GAMEBOY_COLOR_4); bar.setScrollFactors(0, 0); powerBar.add(bar); } }
override public void create() { base.create(); FlxG.resetHud(); makeCave(1.0f, Color.White); FlxSprite avatar = new FlxSprite(0, FlxG.height - 64); avatar.loadGraphic(FlxG.Content.Load <Texture2D>("flixel/surt/race_or_die"), true, false, 64, 64); avatar.addAnimation("Static", new int[] { 2 }, 0, true); avatar.play("Static"); avatar.setScrollFactors(0, 0); add(avatar); p = new FlxPath(null); addPathPointWithMarker(40.0f, 40.0f, 0); addPathPointWithMarker(522.67800098f, 342.106739267f, 1); addPathPointWithMarker(582.8467536f, 603.25142048f, 2); addPathPointWithMarker(531.13384868f, 263.27163512f, 3); addPathPointWithMarker(1447.02681801f, 449.15789055f, 4); addPathPointWithMarker(1201.74908191f, 528.33347167f, 5); addPathPointWithMarker(147.07640576f, 672.46462447f, 6); addPathPointWithMarker(199.62346884f, 584.58110087f, 7); addPathPointWithMarker(108.19931517f, 355.52333218f, 8); addPathPointWithMarker(698.584671041f, 174.70156601f, 9); for (int i = 0; i < 9; i++) { FlxLine line = new FlxLine(0, 0, new Vector2(p.nodes[i].X, p.nodes[i].Y), new Vector2(p.nodes[i + 1].X, p.nodes[i + 1].Y), Color.White, 2); add(line); } car = new FlxSprite(40, 40); car.loadGraphic(FlxG.Content.Load <Texture2D>("flixel/surt/race_or_die"), true, false, 64, 64); //car.addAnimation("Static", new int[] { 8 }, 0, true); //car.play("Static"); car.frame = 8; car.setDrags(5, 5); add(car); car.path = p; car.pathCornering = 5.0f; car.pathAngleOffset = 180; //car.pathSpeed = 500.0f; car.followPath(p, 250.0f, FlxSprite.PATH_LOOP_FORWARD, true); FlxG.follow(car, 5.0f); FlxG.followBounds(0, 0, 100 * 16, 100 * 16); for (int i = 0; i < 7; i++) { p = new FlxPath(null); p.add(40.0f, 40.0f); p.add(522.67800098f + FlxU.random(1, 100), 342.106739267f + FlxU.random(1, 100)); p.add(582.8467536f, 603.25142048f + FlxU.random(1, 1200)); p.add(531.13384868f, 263.27163512f + FlxU.random(1, 1200)); p.add(1447.02681801f, 449.15789055f + FlxU.random(1, 1200)); p.add(1201.74908191f, 528.33347167f + FlxU.random(1, 1200)); p.add(147.07640576f, 672.46462447f + FlxU.random(1, 1200)); p.add(199.62346884f, 584.58110087f + FlxU.random(1, 1200)); p.add(108.19931517f, 355.52333218f + FlxU.random(1, 1200)); p.add(698.584671041f, 174.70156601f + FlxU.random(1, 2100)); car = new FlxSprite(40, 40); car.loadGraphic(FlxG.Content.Load <Texture2D>("flixel/surt/race_or_die"), true, false, 64, 64); //car.addAnimation("Static", new int[] { 8 }, 0, true); //car.play("Static"); car.frame = 6 + i; car.setDrags(5, 5); add(car); car.path = p; car.pathCornering = 5.0f; car.pathAngleOffset = 180; //car.pathSpeed = 500.0f; car.followPath(p, 50.0f + (i * 30), FlxSprite.PATH_LOOP_FORWARD, true); } }