示例#1
0
        /// <summary>
        /// Creates a new <code>FlxButton</code> object with a gray background
        /// and a callback function on the UI thread.
        /// </summary>
        /// <param name="X">The X position of the button.</param>
        /// <param name="Y">The Y position of the button.</param>
        /// <param name="Callback">The function to call whenever the button is clicked.</param>
        public FlxButton(int X, int Y, FlxButtonClick Callback)
            : base()
        {
            x          = X;
            y          = Y;
            width      = 100;
            height     = 20;
            _off       = new FlxSprite().createGraphic((int)width, (int)height, new Color(0x7f, 0x7f, 0x7f));
            _off.solid = false;
            add(_off, true);
            _on       = new FlxSprite().createGraphic((int)width, (int)height, Color.White);
            _on.solid = false;
            add(_on, true);
            _offT        = null;
            _onT         = null;
            _callback    = Callback;
            _onToggle    = false;
            _pressed     = false;
            _initialized = false;
            _sf          = Vector2.Zero;
            pauseProof   = false;

            _controllerButtonIndex = -1;
            //_controllerButton = new FlxSprite((int)width+5,0);
            //_controllerButton.loadGraphic(FlxG.Content.Load<Texture2D>("buttons/BP3_SSTRIP_32"),true,false,32,32);
            //_controllerButton.solid = false;
            ////_controllerButton.scale
            //add(_controllerButton, true);
        }
示例#2
0
        /// <summary>
        /// Creates a new <code>FlxButton</code> object with a gray background
        /// and a callback function on the UI thread.
        /// Also appends a GamePad symbol to allow for using a gamepad to select the menu.
        /// </summary>
        /// <param name="X">The X position of the button.</param>
        /// <param name="Y">The Y position of the button.</param>
        /// <param name="Callback">The function to call whenever the button is clicked.</param>
        /// <param name="Button">Button number. Uses FlxButton.ControlPad** to select a button</param>
        public FlxButton(int X, int Y, FlxButtonClick Callback, int Button)
            : base()
        {
            x          = X;
            y          = Y;
            width      = 100;
            height     = 20;
            _off       = new FlxSprite().createGraphic((int)width, (int)height, new Color(0x7f, 0x7f, 0x7f));
            _off.solid = false;
            add(_off, true);
            _on       = new FlxSprite().createGraphic((int)width, (int)height, Color.White);
            _on.solid = false;
            add(_on, true);
            _offT                  = null;
            _onT                   = null;
            _callback              = Callback;
            _onToggle              = false;
            _pressed               = false;
            _initialized           = false;
            _sf                    = Vector2.Zero;
            pauseProof             = false;
            _controllerButtonIndex = Button;

            //_controllerButton = new FlxSprite((int)width + 5, 0);
            //_controllerButton.loadGraphic(FlxG.Content.Load<Texture2D>("buttons/BP3_SSTRIP_32"), true, false, 31, 32);
            //_controllerButton.width = 29;
            //_controllerButton.height = 30;
            //_controllerButton.offset.X = 1;
            //_controllerButton.offset.Y = 1;
            //_controllerButton.addAnimation("frame", new int[] {Button});
            //_controllerButton.play("frame");
            //_controllerButton.solid = false;
            //add(_controllerButton, true);
        }
示例#3
0
        public FlxRecord()
        {
            vcrGroup = new FlxGroup();


            // Customizable things
            filename   = "File";
            controller = PlayerIndex.One;


            //int xPos = 150;
            int yPos = 30;


            openSprite = new FlxSprite(130, yPos);
            openSprite.loadGraphic(FlxG.Content.Load <Texture2D>("flixel/vcr/open"));
            openSprite.setScrollFactors(0, 0);
            openSprite.debugName = "open";
            vcrGroup.add(openSprite);
            openSprite.boundingBoxOverride = false;

            pauseSprite = new FlxSprite(230, yPos);
            pauseSprite.loadGraphic(FlxG.Content.Load <Texture2D>("flixel/vcr/pause"));
            pauseSprite.setScrollFactors(0, 0);
            pauseSprite.debugName = "pause";
            vcrGroup.add(pauseSprite);
            pauseSprite.boundingBoxOverride = false;

            playSprite = new FlxSprite(330, yPos);
            playSprite.loadGraphic(FlxG.Content.Load <Texture2D>("flixel/vcr/play"));
            playSprite.setScrollFactors(0, 0);
            playSprite.debugName = "play";
            vcrGroup.add(playSprite);
            playSprite.boundingBoxOverride = false;

            recordSprite = new FlxSprite(430, yPos);
            recordSprite.loadGraphic(FlxG.Content.Load <Texture2D>("flixel/vcr/record_on"));
            recordSprite.setScrollFactors(0, 0);
            recordSprite.debugName = "record";
            vcrGroup.add(recordSprite);
            recordSprite.boundingBoxOverride = false;

            restartSprite = new FlxSprite(530, yPos);
            restartSprite.loadGraphic(FlxG.Content.Load <Texture2D>("flixel/vcr/restart"));
            restartSprite.setScrollFactors(0, 0);
            restartSprite.debugName = "restart";
            vcrGroup.add(restartSprite);
            restartSprite.boundingBoxOverride = false;

            stopSprite = new FlxSprite(630, yPos);
            stopSprite.loadGraphic(FlxG.Content.Load <Texture2D>("flixel/vcr/stop"));
            stopSprite.setScrollFactors(0, 0);
            stopSprite.debugName = "stop";
            vcrGroup.add(stopSprite);

            stopSprite.boundingBoxOverride = false;

            infoText = new FlxText(360, yPos, FlxG.width);
            infoText.boundingBoxOverride = false;
        }
示例#4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="Graphics"></param>
        /// <param name="color"></param>
        /// <param name="rows"></param>
        /// <param name="cols"></param>
        /// <param name="width"></param>
        /// <param name="height"></param>
        /// <param name="angle"></param>
        /// <param name="angularVelocity"></param>
        /// <param name="speed">Speed 0.001 is slow. 1 = transition over 1 frame.</param>
        /// <returns></returns>
        public FlxTransition createSprites(Texture2D Graphics, Color color, int rows, int cols, int width, int height, float angle, float angularVelocity, float speed)
        {
            members = new List <FlxObject>();

            FlxSprite s;

            _speed = speed;

            for (int _y = 0; _y < rows; _y++)
            {
                for (int _x = 0; _x < cols; _x++)
                {
                    //Console.WriteLine(":::: z{0} w{1} h{2} x{3} y{4} ", FlxG.zoom, width, height, _x, _y);

                    s = new FlxSprite(width * _y * 4, height * _x * 4);

                    if (Graphics == null)
                    {
                        s.loadGraphic(FlxG.Content.Load <Texture2D>("flixel/transitionBlack_40x40"), false, false, width, height);
                    }
                    else
                    {
                        s.loadGraphic(Graphics, false, false, width, height);
                    }

                    if (FlxG.buildDescription == "GAMEBOY")
                    {
                        s.color = new Color(77, 81, 60);
                    }
                    else
                    {
                        s.color = new Color(0, 0, 0);
                    }


                    s.angle = angle;

                    s.angularVelocity = angularVelocity + (angularVelocity * _y);

                    s.scale = 0.0f;

                    s.scrollFactor.X = 0;
                    s.scrollFactor.Y = 0;

                    s.solid = false;
                    s.boundingBoxOverride = false;

                    add(s);
                }
            }


            return(this);
        }
示例#5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="x">The x coordinate location of the resulting bar (in world pixels)</param>
        /// <param name="y">The y coordinate location of the resulting bar (in world pixels)</param>
        /// <param name="direction">One of the FlxBar.FILL_ constants (such as FILL_LEFT_TO_RIGHT, FILL_TOP_TO_BOTTOM etc)</param>
        /// <param name="width">The width of the bar in pixels</param>
        /// <param name="height">The height of the bar in pixels</param>
        /// <param name="parentRef">A reference to an object in your game that you wish the bar to track</param>
        /// <param name="variable">The variable of the object that is used to determine the bar position. For example if the parent was an FlxSprite this could be "health" to track the health value</param>
        /// <param name="min">The minimum value. I.e. for a progress bar this would be zero (nothing loaded yet)</param>
        /// <param name="max">The maximum value the bar can reach. I.e. for a progress bar this would typically be 100.</param>
        /// <param name="border">Include a 1px border around the bar? (if true it adds +2 to width and height to accommodate it)</param>
        public FlxBar(int x,
                      int y,
                      uint direction      = FILL_LEFT_TO_RIGHT,
                      uint width          = 100,
                      uint height         = 10,
                      FlxSprite parentRef = null,
                      string variable     = "",
                      float min           = 0,
                      float max           = 100,
                      bool border         = false)
            : base()
        {
            barWidth  = width;
            barHeight = height;
            _border   = border;
            //if (border)
            //{
            //    makeGraphic(barWidth + 2, barHeight + 2, 0xffffffff, true);
            //    filledBarPoint = new Point(1, 1);
            //}

            emptyBar  = new FlxSprite(x, y).createGraphic((int)width, (int)height, Color.DarkSlateGray);
            filledBar = new FlxSprite(x, y).createGraphic((int)width, (int)height, Color.Green);

            if (_border)
            {
                outline = new FlxSprite(x - 1, y - 1).createGraphic((int)width + 2, (int)height + 2, Color.LightGray);
            }
            if (parentRef != null)
            {
                parent         = parentRef;
                parentVariable = variable;
            }

            //setFillDirection(direction);

            setRange(min, max);

            //createFilledBar(0xff005100, 0xff00F400, border);

            //emptyKill = false;

            _text = new FlxText(x, y, 100);
            _text.setFormat(null, 1, Color.White, FlxJustification.Left, Color.Black);
            _text.text = variable;

            health = max;
        }
示例#6
0
 /// <summary>
 /// Instantiates a new camera at the specified location, with the specified size and zoom level.
 /// </summary>
 /// <param name="X">X location of the camera's display in pixels. Uses native, 1:1 resolution, ignores zoom.</param>
 /// <param name="Y">Y location of the camera's display in pixels. Uses native, 1:1 resolution, ignores zoom.</param>
 /// <param name="Width">The width of the camera display in pixels.</param>
 /// <param name="Height">The height of the camera display in pixels.</param>
 /// <param name="Zoom">The initial zoom level of the camera.  A zoom level of 2 will make all pixels display at 2x resolution.</param>
 public FlxCamera(int X, int Y, int Width, int Height, float Zoom)
 {
     x      = X;
     y      = Y;
     width  = Width;
     height = Height;
     target = null;
     scroll = new Vector2();
     bounds = new Rectangle();
     screen = new FlxSprite();
     screen.createGraphic(0, 0, Color.Black);
     bgColor = FlxG.backColor;
     angle   = 0;
     color   = Color.White;
     zoom    = Zoom;
 }
示例#7
0
        /// <summary>
        /// Creates the sprites you need for a Transition.
        /// </summary>
        /// <param name="Graphics">A graphic to use for the transition.</param>
        /// <param name="color">The color to use if you're not using a texture</param>
        /// <param name="rows">Rows</param>
        /// <param name="cols">Columns</param>
        /// <param name="width">Width</param>
        /// <param name="height">Height</param>
        /// <returns>A FlxTransition</returns>
        public FlxTransition createSprites(Texture2D Graphics, Color color, int rows, int cols, int width, int height)
        {
            members = new List <FlxObject>();

            FlxSprite s;

            for (int _y = 0; _y < rows; _y++)
            {
                for (int _x = 0; _x < cols; _x++)
                {
                    s = new FlxSprite(width * _y * FlxG.zoom, height * _x * FlxG.zoom);

                    s.loadGraphic(FlxG.Content.Load <Texture2D>("flixel/transition_30x30"), false, false, width, height);

                    if (FlxG.buildDescription == "GAMEBOY")
                    {
                        s.color = new Color(77, 81, 60);
                    }
                    else
                    {
                        s.color = new Color(0, 0, 0);
                    }

                    //s.angle = 45;

                    s.scale = FlxG.zoom;

                    //s.angularVelocity = 15;
                    //s.scrollFactor = Vector2.Zero;
                    s.scrollFactor.X = 0;
                    s.scrollFactor.Y = 0;

                    s.solid = false;
                    s.boundingBoxOverride = false;

                    add(s);
                }
            }


            return(this);
        }
示例#8
0
        /// <summary>
        /// Initialize the console.
        /// </summary>
        /// <param name="targetLeft">Target Left</param>
        /// <param name="targetWidth">Target Width</param>
        public FlxConsole(int targetLeft, int targetWidth)
        {
            visible = false;

            _FPS = new int[8];

            _consoleRect = new Rectangle(FlxG.spriteBatch.GraphicsDevice.Viewport.X, 0,
                                         FlxG.spriteBatch.GraphicsDevice.Viewport.Width,
                                         FlxG.spriteBatch.GraphicsDevice.Viewport.Height);

            width  = FlxG.spriteBatch.GraphicsDevice.Viewport.Width;
            height = FlxG.spriteBatch.GraphicsDevice.Viewport.Height;
            dx     = (int)(width * 0.05);
            dy     = (int)(height * 0.05);

            _titleSafeRect = new Rectangle(dx * 2, dy * 2,
                                           width - 4 * dx,
                                           height - 4 * dy);

            _consoleColor = new Color(0, 0, 0, 0x7F);

            _consoleText        = new FlxText(targetLeft + (dx * 2), -800, targetWidth, "").setFormat(null, 1, Color.White, FlxJustification.Left, Color.White);
            _consoleText.height = FlxG.height; //FlxG.spriteBatch.GraphicsDevice.Viewport.Height;
            _consoleText.boundingBoxOverride = false;

            _consoleCommand      = new FlxText(targetLeft + (dx * 2) + 50, -800, targetWidth, "").setFormat(null, 1, Color.HotPink, FlxJustification.Left, Color.Black);
            _consoleCommand.text = "";
            _consoleCommand.boundingBoxOverride = false;

            _consoleCheatActivated = new FlxSprite(targetLeft + (dx * 2), -800, FlxG.Content.Load <Texture2D>("flixel/vcr/cheat_on"));
            _consoleCheatActivated.setScrollFactors(0, 0);
            _consoleCheatActivated.boundingBoxOverride = false;

            _consoleFPS = new FlxText(targetLeft + targetWidth - (dx * 3), -800, 30, "").setFormat(null, 2, Color.White, FlxJustification.Right, Color.White);
            _consoleFPS.boundingBoxOverride = false;

            _consoleLines = new List <string>();

            MAX_CONSOLE_LINES = (FlxG.spriteBatch.GraphicsDevice.Viewport.Height / (int)(_consoleText.font.MeasureString("Qq").Y)) - 1;

            vcr = new FlxRecord();
        }
示例#9
0
        virtual public FlxSprite emitParticleAndReturnSprite()
        {
            _counter++;
            FlxSprite s = members[_particle] as FlxSprite;

            s.visible    = true;
            s.exists     = true;
            s.active     = true;
            s.x          = x - ((int)s.width >> 1) + FlxU.random() * width;
            s.y          = y - ((int)s.height >> 1) + FlxU.random() * height;
            s.velocity.X = minParticleSpeed.X;
            if (minParticleSpeed.X != maxParticleSpeed.X)
            {
                s.velocity.X += FlxU.random() * (maxParticleSpeed.X - minParticleSpeed.X);
            }
            s.velocity.Y = minParticleSpeed.Y;
            if (minParticleSpeed.Y != maxParticleSpeed.Y)
            {
                s.velocity.Y += FlxU.random() * (maxParticleSpeed.Y - minParticleSpeed.Y);
            }
            s.acceleration.Y  = gravity;
            s.angularVelocity = minRotation;
            if (minRotation != maxRotation)
            {
                s.angularVelocity += FlxU.random() * (maxRotation - minRotation);
            }
            if (s.angularVelocity != 0)
            {
                s.angle = FlxU.random() * 360 - 180;
            }
            s.drag.X = particleDrag.X;
            s.drag.Y = particleDrag.Y;
            _particle++;
            if (_particle >= members.Count)
            {
                _particle = 0;
            }
            s.onEmit();
            justEmitted = true;
            return(s);
        }
示例#10
0
        //@benbaird initializes the console, the pause overlay, and the soundbar
        private void initConsole()
        {
            //initialize the debug console
            _console = new FlxConsole(targetLeft, targetWidth);

            _console.log(FlxG.LIBRARY_NAME +
                         " v" + FlxG.LIBRARY_MAJOR_VERSION.ToString() + "." + FlxG.LIBRARY_MINOR_VERSION.ToString());
            _console.log("---------------------------------------");

            //Pause screen popup
            _pausePanel = new FlxPause();
            if (_helpStrings != null)
            {
                _pausePanel.helpX      = _helpStrings[0];
                _pausePanel.helpC      = _helpStrings[1];
                _pausePanel.helpMouse  = _helpStrings[2];
                _pausePanel.helpArrows = _helpStrings[3];
            }

            //Sound Tray popup
            _soundTrayRect    = new Rectangle((FlxG.width - 80) / 2, -30, 80, 30);
            _soundTrayVisible = false;

            _soundCaption = new FlxText((FlxG.width - 80) / 2, -10, 80, "VOLUME");
            _soundCaption.setFormat(null, 1, Color.White, FlxJustification.Center, Color.White).height = 10;

            int bx = 10;
            int by = 14;

            _soundTrayBars = new FlxSprite[10];
            for (int i = 0; i < 10; i++)
            {
                _soundTrayBars[i]              = new FlxSprite(_soundTrayRect.X + (bx * 1), -i, null);
                _soundTrayBars[i].width        = 4;
                _soundTrayBars[i].height       = i + 1;
                _soundTrayBars[i].scrollFactor = Vector2.Zero;
                bx += 6;
                by--;
            }
        }
示例#11
0
        override public void create()
        {
            base.create();
            Registry.levelSize = Registry.getLevelSize();

            FlxG.elapsedTotal = 0;

            add(SpriteFactory.createCave());

            hero = SpriteFactory.createSprite(new Dictionary<string, string> { { "Name", "CharacterPlayerControlled" }, 
            { "x", (((int)Registry.levelSize.X * Registry.tileSize) / 2).ToString() }, { "y", (((int)Registry.levelSize.X * Registry.tileSize) / 2).ToString() } });

            createStaircase();

            
            enemies = new FlxGroup();
            addRandomObjects(5 * Registry.levelNumber, "CharacterComputerControlled", enemies);
            add(enemies);

            pickups = new FlxGroup();
            addRandomObjects(55, "PickUp", pickups);
            add(pickups);


            add(hero);

            FlxG.follow(hero, 9);
            FlxG.followBounds(0, 0, (int)Registry.levelSize.X * Registry.tileSize, (int)Registry.levelSize.Y * Registry.tileSize);

            //FlxG.showBounds = true;
            //add(SpriteFactory.createTileblock(new Dictionary<string, string> { { "Name", "UIBox" }, { "x", "10" }, { "y", "10" }, { "width", "64" }, { "height", "32" } }));

            add(SpriteFactory.createSprite(new Dictionary<string, string> { { "Name", "MoveCounter" }, { "x", "-1" }, { "y", "-1" } }));

            add(battleUI = new BattleUI());


            add(messageBox = new MessageBox());

        }
示例#12
0
        public override void update()
        {
            if (_f == null)
            {
                _f = new List <FlxLogoPixel>();
                int   scale = 10;
                float pwrscale;

                int pixelsize = (FlxG.height / scale);
                int top       = (FlxG.height / 2) - (pixelsize * 2);
                int left      = (FlxG.width / 2) - pixelsize;

                pwrscale = ((float)pixelsize / 24f);

                //Add logo pixels
                add(new FlxLogoPixel(left + pixelsize, top, pixelsize, 0, _fc));
                add(new FlxLogoPixel(left, top + pixelsize, pixelsize, 1, _fc));
                add(new FlxLogoPixel(left, top + (pixelsize * 2), pixelsize, 2, _fc));
                add(new FlxLogoPixel(left + pixelsize, top + (pixelsize * 2), pixelsize, 3, _fc));
                add(new FlxLogoPixel(left, top + (pixelsize * 3), pixelsize, 4, _fc));

                FlxSprite pwr = new FlxSprite((FlxG.width - (int)((float)_poweredBy.Width * pwrscale)) / 2, top + (pixelsize * 4) + 16, _poweredBy);
                pwr.loadGraphic(_poweredBy, false, false, (int)((float)_poweredBy.Width * pwrscale), (int)((float)_poweredBy.Height * pwrscale));

                pwr.color = _fc;
                pwr.scale = pwrscale;
                add(pwr);

                _fSound.Play(FlxG.volume, 0f, 0f);
            }

            _logoTimer += FlxG.elapsed;

            base.update();

            if (_logoTimer > 2.5f)
            {
                FlxG.state = _nextScreen;
            }
        }
示例#13
0
        public override void update()
        {
            if (_f == null)
            {
                _f = new List<FlxLogoPixel>();
                int scale = 10;
                float pwrscale;

                int pixelsize = (FlxG.height / scale);
                int top = (FlxG.height / 2) - (pixelsize * 2);
                int left = (FlxG.width / 2) - pixelsize;

                pwrscale = ((float)pixelsize / 24f);

                //Add logo pixels
                add(new FlxLogoPixel(left + pixelsize, top, pixelsize, 0, _fc));
                add(new FlxLogoPixel(left, top + pixelsize, pixelsize, 1, _fc));
                add(new FlxLogoPixel(left, top + (pixelsize * 2), pixelsize, 2, _fc));
                add(new FlxLogoPixel(left + pixelsize, top + (pixelsize * 2), pixelsize, 3, _fc));
                add(new FlxLogoPixel(left, top + (pixelsize * 3), pixelsize, 4, _fc));

                FlxSprite pwr = new FlxSprite((FlxG.width - (int)((float)_poweredBy.Width * pwrscale)) / 2, top + (pixelsize * 4) + 16, _poweredBy);
                pwr.loadGraphic(_poweredBy, false, false, (int)((float)_poweredBy.Width * pwrscale), (int)((float)_poweredBy.Height * pwrscale));

                pwr.color = _fc;
                pwr.scale = pwrscale;
                add(pwr);

                _fSound.Play(FlxG.volume, 0f, 0f);
            }

            _logoTimer += FlxG.elapsed;

            base.update();

            if (_logoTimer > 2.5f)
            {
                FlxG.state = _nextScreen;
            }
        }
示例#14
0
 /**
  * Creates a new <code>FlxButton</code> object with a gray background
  * and a callback function on the UI thread.
  *
  * @param	X			The X position of the button.
  * @param	Y			The Y position of the button.
  * @param	Callback	The function to call whenever the button is clicked.
  */
 public FlxButton(int X, int Y, FlxButtonClick Callback)
     : base()
 {
     x          = X;
     y          = Y;
     width      = 100;
     height     = 20;
     _off       = new FlxSprite().createGraphic((int)width, (int)height, new Color(0x7f, 0x7f, 0x7f));
     _off.solid = false;
     add(_off, true);
     _on       = new FlxSprite().createGraphic((int)width, (int)height, Color.White);
     _on.solid = false;
     add(_on, true);
     _offT        = null;
     _onT         = null;
     _callback    = Callback;
     _onToggle    = false;
     _pressed     = false;
     _initialized = false;
     _sf          = Vector2.Zero;
     pauseProof   = false;
 }
示例#15
0
 /// <summary>
 /// Set your own image as the button background.
 /// </summary>
 /// <param name="Image">A FlxSprite object to use for the button background.</param>
 /// <param name="ImageHighlight">A FlxSprite object to use for the button background when highlighted (optional).</param>
 /// <returns>This FlxButton instance (nice for chaining stuff together, if you're into that).</returns>
 public FlxButton loadGraphic(FlxSprite Image, FlxSprite ImageHighlight)
 {
     _off = replace(_off, Image) as FlxSprite;
     if (ImageHighlight == null)
     {
         if (_on != _off)
         {
             remove(_on);
         }
         _on = _off;
     }
     else
     {
         _on = replace(_on, ImageHighlight) as FlxSprite;
     }
     _on.solid         = _off.solid = false;
     _off.scrollFactor = scrollFactor;
     _on.scrollFactor  = scrollFactor;
     width             = _off.width;
     height            = _off.height;
     refreshHulls();
     return(this);
 }
示例#16
0
        public override void create()
        {
            base.create();

            ImgTech=FlxG.Content.Load<Texture2D>("Mode/tech_tiles");
            ImgDirtTop=FlxG.Content.Load<Texture2D>("Mode/dirt_top");
            ImgDirt=FlxG.Content.Load<Texture2D>("Mode/dirt");
            ImgNotch=FlxG.Content.Load<Texture2D>("Mode/notch");
            ImgGibs=FlxG.Content.Load<Texture2D>("Mode/gibs");
            ImgSpawnerGibs = FlxG.Content.Load<Texture2D>("Mode/spawner_gibs");

            FlxG.mouse.hide();
            reload = false;

            //get the gibs set up and out of the way
            _littleGibs = new FlxEmitter();
            _littleGibs.delay = 3;
            _littleGibs.setXSpeed(-150,150);
            _littleGibs.setYSpeed(-200,0);
            _littleGibs.setRotation(-720,-720);
            _littleGibs.createSprites(ImgGibs,100,true,0.5f,0.65f);
            _bigGibs = new FlxEmitter();
            _bigGibs.setXSpeed(-200,200);
            _bigGibs.setYSpeed(-300,0);
            _bigGibs.setRotation(-720,-720);
            _bigGibs.createSprites(ImgSpawnerGibs,50,true,0.5f,0.35f);

            //level generation needs to know about the spawners (and thusly the bots, players, etc)
            _blocks = new FlxGroup();
            _decorations = new FlxGroup();
            _bullets = new FlxGroup();
            _player = new Player(316,300,_bullets.members,_littleGibs);
            _bots = new FlxGroup();
            _botBullets = new FlxGroup();
            _spawners = new FlxGroup();

            //simple procedural level generation
            int i;
            int r = 160;
            FlxTileblock b;

            b = new FlxTileblock(0,0,640,16);
            b.loadGraphic(ImgTech);
            _blocks.add(b);

            b = new FlxTileblock(0,16,16,640-16);
            b.loadGraphic(ImgTech);
            _blocks.add(b);

            b = new FlxTileblock(640-16,16,16,640-16);
            b.loadGraphic(ImgTech);
            _blocks.add(b);

            b = new FlxTileblock(16,640-24,640-32,8);
            b.loadGraphic(ImgDirtTop);
            _blocks.add(b);

            b = new FlxTileblock(16,640-16,640-32,16);
            b.loadGraphic(ImgDirt);
            _blocks.add(b);

            buildRoom(r * 0, r * 0, true);
            buildRoom(r*1,r*0);
            buildRoom(r*2,r*0);
            buildRoom(r * 3, r * 0, true);
            buildRoom(r * 0, r * 1, true);
            buildRoom(r*1,r*1);
            buildRoom(r*2,r*1);
            buildRoom(r * 3, r * 1, true);
            buildRoom(r*0,r*2);
            buildRoom(r*1,r*2);
            buildRoom(r*2,r*2);
            buildRoom(r*3,r*2);
            buildRoom(r*0,r*3,true);
            buildRoom(r*1,r*3);
            buildRoom(r*2,r*3);
            buildRoom(r*3,r*3,true);

            //Add bots and spawners after we add blocks to the state,
            // so that they're drawn on top of the level, and so that
            // the bots are drawn on top of both the blocks + the spawners.
            add(_spawners);
            add(_littleGibs);
            add(_bigGibs);
            add(_blocks);
            add(_decorations);
            add(_bots);

            //actually create the bullets now
            for(i = 0; i < 50; i++)
                _botBullets.add(new BotBullet());
            for(i = 0; i < 8; i++)
                _bullets.add(new Bullet());

            //add player and set up scrolling camera
            add(_player);
            FlxG.follow(_player,2.5f);
            FlxG.followAdjust(0.5f,0.0f);
            FlxG.followBounds(0,0,640,640);

            //add gibs + bullets to scene here, so they're drawn on top of pretty much everything
            add(_botBullets);
            add(_bullets);

            //finally we are going to sort things into a couple of helper groups.
            //we don't add these to the state, we just use them for collisions later!
            _enemies = new FlxGroup();
            _enemies.add(_botBullets);
            _enemies.add(_spawners);
            _enemies.add(_bots);
            _objects = new FlxGroup();
            _objects.add(_botBullets);
            _objects.add(_bullets);
            _objects.add(_bots);
            _objects.add(_player);
            _objects.add(_littleGibs);
            _objects.add(_bigGibs);

            //HUD - score
            Vector2 ssf = new Vector2(0,0);
            _score = new FlxText(0,0,FlxG.width);
            _score.color = new Color (0xd8, 0xeb, 0xa2);
            _score.scale = 2;
            _score.alignment = FlxJustification.Center;
            _score.scrollFactor = ssf;
            _score.shadow = new Color(0x13, 0x1c, 0x1b);
            add(_score);
            if (FlxG.scores.Count < 2)
            {
                FlxG.scores.Add(0);
                FlxG.scores.Add(0);
            }

            //HUD - highest and last scores
            _score2 = new FlxText(FlxG.width/2,0,FlxG.width/2);
            _score2.color = new Color(0xd8, 0xeb, 0xa2);
            _score2.alignment = FlxJustification.Right;
            _score2.scrollFactor = ssf;
            _score2.shadow = _score.shadow;
            add(_score2);
            if (FlxG.score > FlxG.scores[0])
                FlxG.scores[0] = FlxG.score;
            if (FlxG.scores[0] != 0)
                _score2.text = "HIGHEST: " + FlxG.scores[0] + "\nLAST: " + FlxG.score;
            FlxG.score = 0;
            _scoreTimer = 0;

            //HUD - the "number of spawns left" icons
            _notches = new List<FlxSprite>();
            FlxSprite tmp;
            for(i = 0; i < 6; i++)
            {
                tmp = new FlxSprite(4+i*10,4);
                tmp.loadGraphic(ImgNotch,true);
                tmp.scrollFactor.X = tmp.scrollFactor.Y = 0;
                tmp.addAnimation("on", new int[] {0});
                tmp.addAnimation("off",new int[] {1});
                tmp.moves = false;
                tmp.solid = false;
                tmp.play("on");
                _notches.Add((FlxSprite)this.add(tmp));
            }

            //HUD - the "gun jammed" notification
            _jamBar = this.add((new FlxSprite(0,FlxG.height-22)).createGraphic(FlxG.width,24, new Color(0x13, 0x1c, 0x1b))) as FlxSprite;
            _jamBar.scrollFactor.X = _jamBar.scrollFactor.Y = 0;
            _jamBar.visible = false;
            _jamText = new FlxText(0,FlxG.height-22,FlxG.width,"GUN IS JAMMED");
            _jamText.color = new Color(0xd8, 0xeb, 0xa2);
            _jamText.scale = 2;
            _jamText.alignment = FlxJustification.Center;
            _jamText.scrollFactor = ssf;
            _jamText.visible = false;
            add(_jamText);

            FlxG.playMusic(SndMode);
            FlxG.flash.start(new Color(0x13, 0x1c, 0x1b), 0.5f, null, false);
            _fading = false;
        }
示例#17
0
        override public void create()
        {
            FlxG.resetHud();
            FlxG.hideHud();

            FlxG.backColor = Color.DarkTurquoise;

            base.create();



            FlxCaveGeneratorExt caveExt = new FlxCaveGeneratorExt(100, 60, 0.42f, 3);
            string[,] caveLevel = caveExt.generateCaveLevel();

            tileGrp = new FlxGroup();

            for (int i = 0; i < caveLevel.GetLength(1); i++)
            {
                for (int y = 0; y < caveLevel.GetLength(0); y++)
                {
                    //string toPrint = tiles[y, i];
                    if (Convert.ToInt32(caveLevel[y, i]) != 0)
                    {
                        FlxSprite x = new FlxSprite(i * 8, y * 8);
                        //x.createGraphic(8, 8, colors[Convert.ToInt32(caveLevel[y, i])]);
                        x.loadGraphic("flixel/autotilesIsland", false, false, 8, 8);
                        //x.color = colors[Convert.ToInt32(caveLevel[y, i])];

                        x.frame = Convert.ToInt32(caveLevel[y, i]);
                        //x.scale = 2;
                        x.angularDrag = 250;
                        //x.setOffset(4, 4);

                        x.@fixed = true;
                        tileGrp.add(x);
                    }
                    //Console.Write(toPrint);
                }

                //Console.WriteLine();
            }

            //string newMap = caveExt.convertMultiArrayStringToString(caveLevel);


            add(tileGrp);

            boats = new FlxGroup();

            for (int i = 0; i < 20; i++)
            {
                Boat b = new Boat((int)FlxU.random(0, FlxG.width), (int)FlxU.random(0, FlxG.height));
                b.velocity.X = FlxU.random(-40, 40);
                b.velocity.Y = FlxU.random(-40, 40);


                boats.add(b);
            }

            add(boats);
        }
示例#18
0
        public FlxEmitter createSprites(Texture2D Graphics, int Quantity, bool Multiple, float Collide, float Bounce)
        {
            members = new List <FlxObject>();
            int       r;
            FlxSprite s;
            int       tf = 1;
            float     sw;
            float     sh;

            if (Multiple)
            {
                s = new FlxSprite();
                s.loadGraphic(Graphics, true);
                tf = s.frames;
            }
            int i = 0;

            while (i < Quantity)
            {
                if ((Collide > 0) && (Bounce > 0))
                {
                    s = new FlxParticle(Bounce) as FlxSprite;
                }
                else
                {
                    s = new FlxSprite();
                }
                if (Multiple)
                {
                    r = (int)(FlxU.random() * tf);
                    //if(BakedRotations > 0)
                    //    s.loadRotatedGraphic(Graphics,BakedRotations,r);
                    //else
                    //{
                    s.loadGraphic(Graphics, true);
                    s.frame = r;
                    //}
                }
                else
                {
                    //if(BakedRotations > 0)
                    //    s.loadRotatedGraphic(Graphics,BakedRotations);
                    //else
                    s.loadGraphic(Graphics);
                }
                if (Collide > 0)
                {
                    sw         = s.width;
                    sh         = s.height;
                    s.width    = (int)(s.width * Collide);
                    s.height   = (int)(s.height * Collide);
                    s.offset.X = (int)(sw - s.width) / 2;
                    s.offset.Y = (int)(sh - s.height) / 2;
                    s.solid    = true;
                }
                else
                {
                    s.solid = false;
                }
                s.exists       = false;
                s.scrollFactor = scrollFactor;
                add(s);
                i++;
            }
            return(this);
        }
示例#19
0
        /// <summary>
        /// @benbaird initializes the console, the pause overlay, and the soundbar
        /// </summary>
        private void initConsole()
        {
            hud = new FlxHud(targetLeft, targetWidth);


            //initialize the debug console
            _console = new FlxConsole(targetLeft, targetWidth);

            _console.log(FlxG.LIBRARY_NAME +
                         " v" + FlxG.LIBRARY_MAJOR_VERSION.ToString() + "." + FlxG.LIBRARY_MINOR_VERSION.ToString());

            // Display some information about the engine we are using.
            Console.WriteLine("\nFlxFactory initialization\nFlixel Details LIBRARY:{0} -- v{1}.{2}", FlxG.LIBRARY_NAME, FlxG.LIBRARY_MAJOR_VERSION, FlxG.LIBRARY_MINOR_VERSION);


            /*
             * Assembly assembly = Assembly.GetExecutingAssembly();
             * FileVersionInfo fileVersionInfo = FileVersionInfo.GetVersionInfo(assembly.Location);
             * string version = fileVersionInfo.ProductVersion;
             * string gameName = System.Reflection.Assembly.GetExecutingAssembly().GetName().Name;
             * Console.WriteLine(gameName + " - Build version: " + version);
             *
             * _console.log(gameName + " - Build version: " + version);
             */


            _console.log("---------------------------------------");



            //Pause screen popup
            _pausePanel = new FlxPause();
            if (_helpStrings != null)
            {
                _pausePanel.helpX      = _helpStrings[0];
                _pausePanel.helpC      = _helpStrings[1];
                _pausePanel.helpMouse  = _helpStrings[2];
                _pausePanel.helpArrows = _helpStrings[3];
            }

            //Sound Tray popup
            _soundTrayRect    = new Rectangle((FlxG.width - 80) / 2, -30, 80, 30);
            _soundTrayVisible = false;

            _soundCaption = new FlxText((FlxG.width - 80) / 2, -10, 80, "VOLUME [=Lower ]=Higher \\=Mute or Unmute");
            _soundCaption.setFormat(null, 1, Color.White, FlxJustification.Center, Color.White).height = 10;

            int bx = 10;
            int by = 14;

            _soundTrayBars = new FlxSprite[10];
            for (int i = 0; i < 10; i++)
            {
                _soundTrayBars[i]              = new FlxSprite(_soundTrayRect.X + (bx * 1), -i, null);
                _soundTrayBars[i].width        = 4;
                _soundTrayBars[i].height       = i + 1;
                _soundTrayBars[i].scrollFactor = Vector2.Zero;
                bx += 6;
                by--;
            }
        }
示例#20
0
        /// <summary>
        /// FlxHud
        /// </summary>
        /// <param name="targetLeft"></param>
        /// <param name="targetWidth"></param>
        public FlxHud(int targetLeft, int targetWidth)
        {
            _consoleRect  = new Rectangle(0, 0, FlxG.spriteBatch.GraphicsDevice.Viewport.Width, FlxG.spriteBatch.GraphicsDevice.Viewport.Height);
            _consoleColor = new Color(0, 0, 0, 0x00);

            visible = false;

            hudGroup = new FlxGroup();
            hudGroup.scrollFactor.X = 0;
            hudGroup.scrollFactor.Y = 0;

            string keys    = "flixel/buttons/MapWhite";
            string xbox360 = "flixel/buttons/Map360";
            string ouya    = "flixel/buttons/MapOuya";

            if (FlxG.buildDescription == "GAMEBOY")
            {
                keys    = "flixel/buttons/MapWhiteGameboy";
                xbox360 = "flixel/buttons/Map360Gameboy";
                ouya    = "flixel/buttons/MapOuyaGameboy";
            }

            p1OriginalPosition = new Vector2(targetLeft, 0);
            p2OriginalPosition = new Vector2(targetLeft, 0);
            p3OriginalPosition = new Vector2(targetLeft, FlxG.spriteBatch.GraphicsDevice.Viewport.Height - 20);
            p4OriginalPosition = new Vector2(targetLeft, FlxG.spriteBatch.GraphicsDevice.Viewport.Height - 20);


            //FlxG.Content.Load<SpriteFont>("flixel/initials/SpaceMarine")

            if (FlxG.hudFont == null)
            {
                p1HudText = new FlxText(targetLeft, 0, targetWidth, "").setFormat(null, 1, Color.White, FlxJustification.Left, Color.White);
                p2HudText = new FlxText(targetLeft, 0, targetWidth, "").setFormat(null, 1, Color.White, FlxJustification.Right, Color.White);
                p3HudText = new FlxText(targetLeft, FlxG.spriteBatch.GraphicsDevice.Viewport.Height - 20, targetWidth, "").setFormat(null, 1, Color.White, FlxJustification.Left, Color.White);
                p4HudText = new FlxText(targetLeft, FlxG.spriteBatch.GraphicsDevice.Viewport.Height - 20, targetWidth, "").setFormat(null, 1, Color.White, FlxJustification.Right, Color.White);
            }
            else
            {
                p1HudText = new FlxText(targetLeft, 0, targetWidth, "").setFormat(FlxG.Content.Load <SpriteFont>(FlxG.hudFont), 1, Color.White, FlxJustification.Left, Color.Black);
                p2HudText = new FlxText(targetLeft, 0, targetWidth, "").setFormat(FlxG.Content.Load <SpriteFont>(FlxG.hudFont), 1, Color.White, FlxJustification.Right, Color.Black);
                p3HudText = new FlxText(targetLeft, FlxG.spriteBatch.GraphicsDevice.Viewport.Height - 20, targetWidth, "").setFormat(FlxG.Content.Load <SpriteFont>(FlxG.hudFont), 1, Color.White, FlxJustification.Left, Color.Black);
                p4HudText = new FlxText(targetLeft, FlxG.spriteBatch.GraphicsDevice.Viewport.Height - 20, targetWidth, "").setFormat(FlxG.Content.Load <SpriteFont>(FlxG.hudFont), 1, Color.White, FlxJustification.Right, Color.Black);
            }


            keyboardButton = new FlxSprite(targetLeft, -1000);
            keyboardButton.loadGraphic(FlxG.Content.Load <Texture2D>(keys), true, false, 100, 100);
            keyboardButton.addAnimation("frame", new int[] { FlxButton.ControlPadA });
            keyboardButton.play("frame");
            keyboardButton.solid               = false;
            keyboardButton.visible             = true;
            keyboardButton.scrollFactor.X      = 0;
            keyboardButton.scrollFactor.Y      = 0;
            keyboardButton.boundingBoxOverride = false;

            xboxButton = new FlxSprite(targetLeft, -1000);
            xboxButton.loadGraphic(FlxG.Content.Load <Texture2D>(xbox360), true, false, 100, 100);
            xboxButton.addAnimation("frame", new int[] { FlxButton.ControlPadA });
            xboxButton.play("frame");
            xboxButton.solid               = false;
            xboxButton.visible             = true;
            xboxButton.scrollFactor.X      = 0;
            xboxButton.scrollFactor.Y      = 0;
            xboxButton.boundingBoxOverride = false;


            ouyaButton = new FlxSprite(targetLeft, -1000);
            ouyaButton.loadGraphic(FlxG.Content.Load <Texture2D>(ouya), true, false, 100, 100);
            ouyaButton.addAnimation("frame", new int[] { FlxButton.ControlPadA });
            ouyaButton.play("frame");
            ouyaButton.solid               = false;
            ouyaButton.visible             = true;
            ouyaButton.scrollFactor.X      = 0;
            ouyaButton.scrollFactor.Y      = 0;
            ouyaButton.boundingBoxOverride = false;


            keyboardDirection = new FlxSprite(targetLeft, -1000);
            keyboardDirection.loadGraphic(FlxG.Content.Load <Texture2D>(keys), true, false, 100, 100);
            keyboardDirection.addAnimation("frame", new int[] { Keyboard_Arrow_Up });
            keyboardDirection.play("frame");
            keyboardDirection.solid               = false;
            keyboardDirection.visible             = true;
            keyboardDirection.scrollFactor.X      = 0;
            keyboardDirection.scrollFactor.Y      = 0;
            keyboardDirection.boundingBoxOverride = false;


            xboxDirection = new FlxSprite(targetLeft, -1000);
            xboxDirection.loadGraphic(FlxG.Content.Load <Texture2D>(xbox360), true, false, 100, 100);
            xboxDirection.addAnimation("frame", new int[] { FlxButton.ControlPadA });
            xboxDirection.play("frame");
            xboxDirection.solid               = false;
            xboxDirection.visible             = true;
            xboxDirection.scrollFactor.X      = 0;
            xboxDirection.scrollFactor.Y      = 0;
            xboxDirection.boundingBoxOverride = false;


            ouyaDirection = new FlxSprite(targetLeft, -1000);
            ouyaDirection.loadGraphic(FlxG.Content.Load <Texture2D>(ouya), true, false, 100, 100);
            ouyaDirection.addAnimation("frame", new int[] { FlxButton.ControlPadA });
            ouyaDirection.play("frame");
            ouyaDirection.solid               = false;
            ouyaDirection.visible             = true;
            ouyaDirection.scrollFactor.X      = 0;
            ouyaDirection.scrollFactor.Y      = 0;
            ouyaDirection.boundingBoxOverride = false;



            //add(_gamePadButton, true);

            timeToShowButton = float.MaxValue;
            _elapsedSinceLastButtonNeeded = 0.0f;
        }
示例#21
0
        public void startBattle(FlxSprite BattleTarget, FlxSprite BattlePlayer)
        {
            if (visible == true) return;

            battleTarget = BattleTarget;
            battlePlayer = BattlePlayer;

            battlePlayer.facing = Flx2DFacing.Left;
            battleTarget.facing = Flx2DFacing.Right;
            
            for (int i = 0; i < 4; i++)
            {
                Key x;
                x = new Key((int)(box.x + (i * 75)), (int)(box.y));
                x.loadGraphic("flixel/buttons/MapWhite", true, false, 100, 100);
                x.frame = directions[FlxU.randomInt(0,3)];
                x.setScrollFactors(0, 0);
                keys.add(x);
            }

            Console.WriteLine("Starting battle");
            visible = true;
            Registry.canMove = false;

            playerTweener.Reset();
            targetTweener.Reset();
            playerTweener.Start();
            targetTweener.Start();

        }
示例#22
0
 public FlxEmitter createSprites(Texture2D Graphics, int Quantity, bool Multiple, float Collide, float Bounce)
 {
     members = new List<FlxObject>();
     int  r;
     FlxSprite s;
     int tf = 1;
     float sw;
     float sh;
     if(Multiple)
     {
         s = new FlxSprite();
         s.loadGraphic(Graphics,true);
         tf = s.frames;
     }
     int i = 0;
     while(i < Quantity)
     {
         if((Collide > 0) && (Bounce > 0))
             s = new FlxParticle(Bounce) as FlxSprite;
         else
             s = new FlxSprite();
         if(Multiple)
         {
             r = (int)(FlxU.random()*tf);
             //if(BakedRotations > 0)
             //    s.loadRotatedGraphic(Graphics,BakedRotations,r);
             //else
             //{
                 s.loadGraphic(Graphics,true);
                 s.frame = r;
             //}
         }
         else
         {
             //if(BakedRotations > 0)
             //    s.loadRotatedGraphic(Graphics,BakedRotations);
             //else
                 s.loadGraphic(Graphics);
         }
         if(Collide > 0)
         {
             sw = s.width;
             sh = s.height;
             s.width = (int)(s.width * Collide);
             s.height = (int)(s.height * Collide);
             s.offset.X = (int)(sw-s.width)/2;
             s.offset.Y = (int)(sh-s.height)/2;
             s.solid = true;
         }
         else
             s.solid = false;
         s.exists = false;
         s.scrollFactor = scrollFactor;
         add(s);
         i++;
     }
     return this;
 }
示例#23
0
        //@benbaird initializes the console, the pause overlay, and the soundbar
        private void initConsole()
        {
            //initialize the debug console
            _console = new FlxConsole(targetLeft, targetWidth);

            _console.log(FlxG.LIBRARY_NAME +
                " v" + FlxG.LIBRARY_MAJOR_VERSION.ToString() + "." + FlxG.LIBRARY_MINOR_VERSION.ToString());
            _console.log("---------------------------------------");

            //Pause screen popup
            _pausePanel = new FlxPause();
            if (_helpStrings != null)
            {
                _pausePanel.helpX = _helpStrings[0];
                _pausePanel.helpC = _helpStrings[1];
                _pausePanel.helpMouse = _helpStrings[2];
                _pausePanel.helpArrows = _helpStrings[3];
            }

            //Sound Tray popup
            _soundTrayRect = new Rectangle((FlxG.width - 80) / 2, -30, 80, 30);
            _soundTrayVisible = false;

            _soundCaption = new FlxText((FlxG.width - 80) / 2, -10, 80, "VOLUME");
            _soundCaption.setFormat(null, 1, Color.White, FlxJustification.Center, Color.White).height = 10;

            int bx = 10;
            int by = 14;
            _soundTrayBars = new FlxSprite[10];
            for(int i = 0; i < 10; i++)
            {
                _soundTrayBars[i] = new FlxSprite(_soundTrayRect.X + (bx * 1), -i, null);
                _soundTrayBars[i].width = 4;
                _soundTrayBars[i].height = i + 1;
                _soundTrayBars[i].scrollFactor = Vector2.Zero;
                bx += 6;
                by--;
            }
        }
示例#24
0
        public override void update()
        {
            //if (FlxG.elapsedFrames == 5)
            //    FlxG.transition.startFadeIn(0.08f);

            if (FlxG.keys.justPressed(Keys.B))
            {
                cheatStorage += "B";
            }
            if (FlxG.keys.justPressed(Keys.U))
            {
                cheatStorage += "U";
            }
            if (FlxG.keys.justPressed(Keys.G))
            {
                cheatStorage += "G";
            }
            if (FlxG.keys.justPressed(Keys.S))
            {
                cheatStorage += "S";
            }

            if (cheatStorage == FlxGlobal.titleScreenDebugMode)
            {
                debugMode.visible = true;
                FlxG.debug        = true;
            }

            _logoTweener.Update(FlxG.elapsedAsGameTime);
            //_logo.y = _logoTweener.Position;

            if (_logoTimer > 1.15f)
            {
                //FlxG.bloom.Visible = true;
                //FlxG.bloom.bloomIntensity += 1.5f;
                //FlxG.bloom.baseIntensity += 1.0f;
                //FlxG.bloom.blurAmount += 1.1f;
            }
            if (_f == null && _logoTimer > 2.5f)
            {
                foreach (FlxLogoSprite item in logoParts.members)
                {
                    item.play("bugs2", true);
                    //item.velocity.Y = FlxU.randomInt(-200, 200);
                    //item.angularVelocity = FlxU.randomInt(120, 240);

                    float offset = FlxG.height;
                    if (item._row < 1)
                    {
                        offset *= -1.0f;
                    }

                    item.t = new Tweener(item.y, item.y + offset, 0.25f + (item._col / 18.0f), Quadratic.EaseInOut);

                    item.t.Reverse();
                    item.t.Start();
                }
                //_logo.visible = false;

                _logoTweener.Reverse();
                _logoTweener.Start();

                //FlxG.flash.start(FlxG.backColor, 1.0f, null, false);

                _f = new List <FlxLogoPixel>();
                int   scale = 10;
                float pwrscale;

                int pixelsize = (FlxG.height / scale);
                int top       = (FlxG.height / 2) - (pixelsize * 2);
                int left      = (FlxG.width / 2) - pixelsize;

                pwrscale = ((float)pixelsize / 24f);

                //Add logo pixels
                add(new FlxLogoPixel(left + pixelsize, top, pixelsize, 0, _fc));
                add(new FlxLogoPixel(left, top + pixelsize, pixelsize, 1, _fc));
                add(new FlxLogoPixel(left, top + (pixelsize * 2), pixelsize, 2, _fc));
                add(new FlxLogoPixel(left + pixelsize, top + (pixelsize * 2), pixelsize, 3, _fc));
                add(new FlxLogoPixel(left, top + (pixelsize * 3), pixelsize, 4, _fc));

                FlxSprite pwr = new FlxSprite((FlxG.width - (int)((float)_poweredBy.Width * pwrscale)) / 2, top + (pixelsize * 4) + 16, _poweredBy);
                pwr.loadGraphic(_poweredBy, false, false, 64);

                //pwr.color = _fc;
                //pwr.scale = pwrscale;
                add(pwr);

                _fSound.Play(FlxG.volume, 0f, 0f);
            }

            _logoTimer += FlxG.elapsed;

            base.update();
            if (FlxG.keys.ONE)
            {
                FlxG.level = 1;
            }
            if (FlxG.keys.TWO)
            {
                FlxG.level = 2;
            }
            if (FlxG.keys.THREE)
            {
                FlxG.level = 3;
            }

            if (FlxG.keys.FOUR)
            {
                FlxG.level = 4;
            }
            if (FlxG.keys.FIVE)
            {
                FlxG.level = 5;
            }
            if (FlxG.keys.SIX)
            {
                FlxG.level = 6;
            }

            if (FlxG.keys.SEVEN)
            {
                FlxG.level = 7;
            }
            if (FlxG.keys.EIGHT)
            {
                FlxG.level = 8;
            }
            if (FlxG.keys.NINE)
            {
                FlxG.level = 9;
            }

            if (_logoTimer > 5.5f || FlxG.keys.SPACE || FlxG.keys.ENTER || FlxG.gamepads.isButtonDown(Buttons.A))
            {
                FlxG.destroySounds(true);

                //FlxG.bloom.Visible = false;

                FlxG.state = _nextScreen;
            }
            if (FlxG.keys.F1 || (FlxG.gamepads.isButtonDown(Buttons.RightStick) && FlxG.gamepads.isButtonDown(Buttons.LeftStick)))
            {
                //FlxG.bloom.Visible = false;
                FlxG.destroySounds(true);
                                #if !__ANDROID__
                FlxG.state = new org.flixel.examples.TestState();
                                #endif
            }
            if (FlxG.keys.F8)
            {
                FlxG.state = new org.flixel.FlxSplash();
                return;
            }
        }
示例#25
0
 /**
  * Creates a new <code>FlxButton</code> object with a gray background
  * and a callback function on the UI thread.
  *
  * @param	X			The X position of the button.
  * @param	Y			The Y position of the button.
  * @param	Callback	The function to call whenever the button is clicked.
  */
 public FlxButton(int X, int Y, FlxButtonClick Callback)
     : base()
 {
     x = X;
     y = Y;
     width = 100;
     height = 20;
     _off = new FlxSprite().createGraphic((int)width, (int)height, new Color(0x7f, 0x7f, 0x7f));
     _off.solid = false;
     add(_off, true);
     _on = new FlxSprite().createGraphic((int)width, (int)height, Color.White);
     _on.solid = false;
     add(_on, true);
     _offT = null;
     _onT = null;
     _callback = Callback;
     _onToggle = false;
     _pressed = false;
     _initialized = false;
     _sf = Vector2.Zero;
     pauseProof = false;
 }
示例#26
0
 /**
  * Set your own image as the button background.
  *
  * @param	Image				A FlxSprite object to use for the button background.
  * @param	ImageHighlight		A FlxSprite object to use for the button background when highlighted (optional).
  *
  * @return	This FlxButton instance (nice for chaining stuff together, if you're into that).
  */
 public FlxButton loadGraphic(FlxSprite Image, FlxSprite ImageHighlight)
 {
     _off = replace(_off, Image) as FlxSprite;
     if (ImageHighlight == null)
     {
         if (_on != _off)
             remove(_on);
         _on = _off;
     }
     else
         _on = replace(_on, ImageHighlight) as FlxSprite;
     _on.solid = _off.solid = false;
     _off.scrollFactor = scrollFactor;
     _on.scrollFactor = scrollFactor;
     width = _off.width;
     height = _off.height;
     refreshHulls();
     return this;
 }
示例#27
0
        private void renderWithOffset(SpriteBatch spriteBatch, FlxSprite obj, float localX, float localY, float localScale)
        {
            float oldX = obj.x;
            float oldY = obj.y;
            float oldScale = obj.scale;
            float oldScrollX = obj.scrollFactor.X;
            float oldScrollY = obj.scrollFactor.Y;

            obj.setScrollFactors(0, 0);
            obj.x = localX;
            obj.y = localY;
            obj.scale = localScale;
            obj.render(spriteBatch);

            obj.setScrollFactors(oldScrollX, oldScrollY);
            obj.x = oldX;
            obj.y = oldY;
            obj.scale = oldScale;
        }
示例#28
0
        public override void create()
        {
            base.create();

            FlxSprite bg = new FlxSprite(0, 0);

            bg.createGraphic(FlxG.width, FlxG.height, FlxG.splashBGColor);
            add(bg);

            _f         = null;
            _poweredBy = FlxG.Content.Load <Texture2D>("flixel/poweredby");
            _fSound    = FlxG.Content.Load <SoundEffect>(FlxG.splashAudioWaveFlixel);

            _initialsLogo = FlxG.Content.Load <Texture2D>(FlxG.splashLogo);

            //_logo = new FlxSprite();
            //_logo.loadGraphic(_initialsLogo, false, false, 216,24);
            //_logo.x = FlxG.width / 2 - 216 / 2;
            //_logo.y = FlxG.height / 2 - 24;
            //add(_logo);

            logoParts = new FlxGroup();

            for (int i = 0; i < 18; i++)
            {
                for (int j = 0; j < 2; j++)
                {
                    _logo = new FlxLogoSprite(i, j);
                    _logo.loadGraphic(_initialsLogo, false, false, 12, 12);
                    _logo.x = (FlxG.width / 2 - 216 / 2) + (i * 12);
                    _logo.y = (FlxG.height / 2 - 24) + (j * 12);
                    _logo.addAnimation("bugs", new int[] { 0, 1, 2, FlxU.randomInt(0, 24), FlxU.randomInt(0, 24), FlxU.randomInt(0, 24), FlxU.randomInt(0, 24), FlxU.randomInt(0, 24), FlxU.randomInt(0, 24), FlxU.randomInt(0, 24), FlxU.randomInt(0, 24), FlxU.randomInt(0, 24), FlxU.randomInt(0, 24), FlxU.randomInt(0, 24), FlxU.randomInt(0, 24), FlxU.randomInt(0, 24), FlxU.randomInt(0, 24), FlxU.randomInt(0, 24),
                                                           (j * 18) + i }, FlxU.randomInt(12, 18), false);

                    _logo.addAnimation("bugs2", new int[] { 0, 1, 2, FlxU.randomInt(0, 24), FlxU.randomInt(0, 24), FlxU.randomInt(0, 24), FlxU.randomInt(0, 24), FlxU.randomInt(0, 24), FlxU.randomInt(0, 24), FlxU.randomInt(0, 24), FlxU.randomInt(0, 24), FlxU.randomInt(0, 24), FlxU.randomInt(0, 24), FlxU.randomInt(0, 24), FlxU.randomInt(0, 24), FlxU.randomInt(0, 24), FlxU.randomInt(0, 24), FlxU.randomInt(0, 24),
                                                            0 }, FlxU.randomInt(18, 24), false);

                    _logo.play("bugs");
                    logoParts.add(_logo);

                    float offset = 25.0f;
                    if (j >= 1)
                    {
                        offset *= -1.0f;
                    }
                    _logo.t = new Tweener((float)(_logo.y + offset), (float)_logo.y, 0.25f + (i / 18.0f), XNATweener.Quadratic.EaseInOut);
                    _logo.t.Start();
                }
            }
            add(logoParts);


            _logoTweener = new Tweener(-150, FlxG.height / 2 - 24, TimeSpan.FromSeconds(0.9f), Bounce.EaseOut);

            SndTag = FlxG.splashAudioWave;
            //FlxG.play(SndTag,1.0f);



            debugMode         = new FlxText(10, 90, 200, "DEBUG MODE!");
            debugMode.visible = false;
            add(debugMode);

            Console.WriteLine(" !!! Type {0} To Enter Debug Mode !!! ", FlxGlobal.titleScreenDebugMode);
        }