Пример #1
0
        private void SetInitialState()
        {
            Active     = true;
            Visible    = true;
            LayerIndex = 0;

            PositionRectangle = new Rectangle(Convert.ToInt32(X), Convert.ToInt32(Y), Width, Height);

            // Surface
            Friction = 0;
            Bounce   = 0;
            CurrentGameArea.Collision.AddCollidableObject(this);

            if (assetName == null)
            {
                int tempTextureId = 0;

                // texture related
                assetName   = AssetName;
                textureId   = GraphicsUtility.LoadTexture(assetName);
                spriteSheet = new SpriteSheetHandler(textureId, 0, 0, 0, 0, TileWidth, TileHeight);
                GraphicsUtility.AddVisibleGameObjects(LayerIndex, this);
            }

            spriteSheet.CurrentFrame = TileNumber;
        }
Пример #2
0
        private void SetInitialState()
        {
            Active     = true;
            Visible    = true;
            LayerIndex = 0;

            // final tile size (individual tiles are 16*16)
            Height = BlockHeight * 16;
            Width  = BlockWidth * 16;

            PositionRectangle = new Rectangle(Convert.ToInt32(X), Convert.ToInt32(Y), Width, Height);

            // Surface
            Friction = 0;
            Bounce   = 0;
            CurrentGameArea.Collision.AddCollidableObject(this);

            if (assetName == null)
            {
                int tempTextureId = 0;

                // texture related
                assetName     = "Sprites\\Game Boy GBC - Mega Man I Dr Wilys Revenge - Ice Mans Stage";
                tempTextureId = GraphicsUtility.LoadTexture(assetName);
                spriteSheet   = new SpriteSheetHandler(tempTextureId, 0, 0, 0, 0, 16, 16);

                // Tile helper
                TiledTextureRenderer renderer = new TiledTextureRenderer();
                renderer.AddTextureId(spriteSheet);

                List <TiledTextureDescriptor> tiles = new List <TiledTextureDescriptor>();
                int spriteIdOffset = 2;
                for (int i = 0; i < BlockHeight; i++)
                {
                    if (i > 0)
                    {
                        spriteIdOffset = 0;
                    }

                    for (int j = 0; j < BlockWidth; j++)
                    {
                        tiles.Add(new TiledTextureDescriptor(j * 16, i * 16, spriteIdOffset + j % 2));
                    }
                }
                textureId = renderer.RenderTexture("tiletest " + Height.ToString() + " " + Width.ToString(), tiles, Width, Height);

                GraphicsUtility.AddVisibleGameObjects(LayerIndex, this);
            }
        }