Exemplo n.º 1
0
        /**
         * You can use this if you have a lot of text parameters to set instead of
         * the individual properties.
         *
         * @param Font The name of the font face for the text display.
         * @param Size The size of the font (in pixels essentially).
         * @param Color The color of the text in 0xRRGGBB format.
         * @param Alignment A string representing the desired alignment
         *        ("left,"right" or "center").
         * @param ShadowColor An int representing the desired text shadow color
         *        0xAARRGGBB format.
         * @param ShadowX The x-position of the shadow, default is 1.
         * @param ShadowY The y-position of the shadow, default is 1.
         *
         * @return This FlxText instance (nice for chaining stuff together, if
         *         you're into that).
         */
        public FlxText setFormat(String Font, float size, Color color, String Alignment, Color ShadowColor, float ShadowX = 1f, float ShadowY = 1f)
        {
            if (Font == null)
            {
                Font = _font;
            }
            _size = (int)FlxU.floor(size);
            if (Font != null && (!Font.Equals(_font) || size != _size))
            {
                try {
                    //_textField = new SpriteBatch(FlxG.loadFont(Font, FlxU.round(Size), _bitmapFontParameter));
                    //_textField = new SpriteBatch(GraphicsDevice);
                } catch (Exception e) {
                    Console.WriteLine(e.Message);
                    FlxG.log(e.Message);
                    //_textField = new SpriteBatch(FlxG.loadFont("org/flixel/data/font/nokiafc.fnt", 22, _bitmapFontParameter));
                }

                _font      = Font;
                LoadedFont = FlxS.ContentManager.Load <SpriteFont> (_font);
            }

            Color = color;
            if (Alignment != null)
            {
                _alignment = (Alignment.ToUpper());
            }
            _shadow  = ShadowColor;
            _shadowX = ShadowX;
            _shadowY = ShadowY;

            calcFrame();

            return(this);
        }
Exemplo n.º 2
0
        // overlapsWithCallBack
        public Boolean overlapsWithCallback(FlxObject Object, Func <FlxObject, FlxObject, Boolean> Callback = null, Boolean FlipCallbackParams = false, FlxPoint Position = null)
        {
            Boolean results = false;

            float X = base.X;
            float Y = base.Y;

            if (Position != null)
            {
                X = Position.X;
                Y = Position.X;
            }

            //Figure out what tiles we need to check against
            int  selectionX      = (int)FlxU.floor((Object.X - X) / _tileWidth);
            int  selectionY      = (int)FlxU.floor((Object.Y - Y) / _tileHeight);
            uint selectionWidth  = (uint)(selectionX + (FlxU.ceil((int)Object.Width / _tileWidth)) + 2);
            uint selectionHeight = (uint)(selectionY + (FlxU.ceil((int)Object.Height / _tileHeight)) + 2);

            //Then bound these coordinates by the map edges
            if (selectionX < 0)
            {
                selectionX = 0;
            }
            if (selectionY < 0)
            {
                selectionY = 0;
            }
            if (selectionWidth > widthInTiles)
            {
                selectionWidth = (uint)widthInTiles;
            }
            if (selectionHeight > heightInTiles)
            {
                selectionHeight = (uint)heightInTiles;
            }

            //Then loop through this selection of tiles and call FlxObject.separate() accordingly
            uint    rowStart = (uint)selectionY * (uint)widthInTiles;
            uint    row      = (uint)selectionY;
            uint    column;
            FlxTile tile;
            Boolean overlapFound;
            float   deltaX = X - Last.X;
            float   deltaY = Y - Last.Y;



            while (row < selectionHeight)
            {
                column = (uint)selectionX;
                while (column < selectionWidth)
                {
                    overlapFound = false;
                    tile         = _tileObjects[(int)_data[(int)(rowStart + column)]] as FlxTile;
                    if (Convert.ToBoolean(tile.AllowCollisions))
                    {
                        tile.X      = X + (int)column * _tileWidth;
                        tile.Y      = Y + (int)row * _tileHeight;
                        tile.Last.X = tile.X - deltaX;
                        tile.Last.Y = tile.Y - deltaY;
                        if (Callback != null)
                        {
                            if (FlipCallbackParams)
                            {
                                overlapFound = Callback(Object, tile);
                            }
                            else
                            {
                                overlapFound = Callback(tile, Object);
                            }
                        }
                        else
                        {
                            overlapFound = (Object.X + Object.Width > tile.X) && (Object.X < tile.X + tile.Width) && (Object.Y + Object.Height > tile.Y) && (Object.Y < tile.Y + tile.Height);
                        }
                        if (overlapFound)
                        {
                            if ((tile.callback != null))
                            {
                                tile.mapIndex = (uint)rowStart + column;
                                tile.callback(tile, Object);
                            }
                            results = true;
                        }
                    }
                    else if ((tile.callback != null))
                    {
                        tile.mapIndex = (uint)rowStart + (uint)column;
                        tile.callback(tile, Object);
                    }
                    column++;
                }
                rowStart += (uint)widthInTiles;
                row++;
            }
            return(results);
        }