示例#1
0
 public virtual Animation Frames(TextureFilm film, params object[] frames)
 {
     this.frames = new RectF[frames.Length];
     for (int i = 0; i < frames.Length; i++)
     {
         this.frames[i] = film.Get(frames[i]);
     }
     return(this);
 }
示例#2
0
        protected internal virtual void UpdateVertices()
        {
            var y1 = _cellH * updated.Top;
            var y2 = y1 + _cellH;

            for (var i = updated.Top; i < updated.Bottom; i++)
            {
                var x1 = _cellW * updated.Left;
                var x2 = x1 + _cellW;

                var pos = i * mapWidth + updated.Left;
                quads.Position(16 * pos);

                for (var j = updated.Left; j < updated.Right; j++)
                {
                    var uv = tileset.Get(data[pos++]);

                    vertices[0] = x1;
                    vertices[1] = y1;

                    vertices[2] = uv.Left;
                    vertices[3] = uv.Top;

                    vertices[4] = x2;
                    vertices[5] = y1;

                    vertices[6] = uv.Right;
                    vertices[7] = uv.Top;

                    vertices[8] = x2;
                    vertices[9] = y2;

                    vertices[10] = uv.Right;
                    vertices[11] = uv.Bottom;

                    vertices[12] = x1;
                    vertices[13] = y2;

                    vertices[14] = uv.Left;
                    vertices[15] = uv.Bottom;

                    quads.Put(vertices);

                    x1  = x2;
                    x2 += _cellW;
                }

                y1  = y2;
                y2 += _cellH;
            }

            updated.SetEmpty();
        }
示例#3
0
        public Tilemap(object tx, TextureFilm tileset)
            : base(0, 0, 0, 0)
        {
            texture      = TextureCache.Get(tx);
            this.tileset = tileset;

            var r = tileset.Get(0);

            _cellW = tileset.Width(r);
            _cellH = tileset.Height(r);

            vertices = new float[16];

            updated = new Rect();
        }
示例#4
0
        public TextureFilm(TextureFilm atlas, object key, int width, int height)
        {
            _texWidth  = atlas._texWidth;
            _texHeight = atlas._texHeight;

            var patch = atlas.Get(key);

            var uw   = (float)width / _texWidth;
            var vh   = (float)height / _texHeight;
            var cols = (int)Width(patch) / width;
            var rows = (int)Height(patch) / height;

            for (var i = 0; i < rows; i++)
            {
                for (var j = 0; j < cols; j++)
                {
                    var rect = new RectF(j * uw, i * vh, (j + 1) * uw, (i + 1) * vh);
                    rect.Offset(patch.Left, patch.Top);
                    Add(i * cols + j, rect);
                }
            }
        }