Exemplo n.º 1
0
        public void AddSprite(Sprite sprite)
        {
            // If the batch is full, draw it, empty and start again.
            if (sprite.VertexPositions.Length + _batchSize > MaxVertexNumber)
            {
                Draw();
            }

            // Add the current sprite vertices to the batch.
            for (int i = 0; i < sprite.VertexPositions.Length; i++)
            {
                _vertexPositions[_batchSize + i] = sprite.VertexPositions[i];
                _vertexColors[_batchSize + i] = sprite.VertexColors[i];
                _vertexUVs[_batchSize + i] = sprite.VertexUVs[i];
            }
            _batchSize += sprite.VertexPositions.Length;
        }
Exemplo n.º 2
0
        public CharacterSprite CreateSprite(char c)
        {
            CharacterData charData = _characterData[c];
            Sprite sprite = new Sprite();
            sprite.Texture = _texture;

            // Setup UVs
            Point topLeft = new Point((float)charData.X / (float)_texture.Width,
                                        (float)charData.Y / (float)_texture.Height);
            Point bottomRight = new Point(topLeft.X + ((float)charData.Width / (float)_texture.Width),
                                          topLeft.Y + ((float)charData.Height / (float)_texture.Height));
            sprite.SetUVs(topLeft, bottomRight);
            sprite.SetWidth(charData.Width);
            sprite.SetHeight(charData.Height);
            sprite.SetColor(new Color(1, 1, 1, 1));

            return new CharacterSprite(sprite, charData);
        }
Exemplo n.º 3
0
 public void DrawSprite(Sprite sprite)
 {
     _batch.AddSprite(sprite);
 }
 public CharacterSprite(Sprite sprite, CharacterData data)
 {
     Data = data;
     Sprite = sprite;
 }