Пример #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
        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();
        }
Пример #3
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);
                }
            }
        }