Esempio n. 1
0
        protected bool reversed; // Used only for the BackAndForth animation mode. When true, animation is going backwards.

        #endregion Fields

        #region Constructors

        public TileAnimation(string name, TilesetAnimationMode mode, int start, int end, int delay, Tileset tileset)
        {
            this.name = name;
            this.mode = mode;
            this.start = start;
            this.end = end;
            this.delay = delay;
            frame_coord = new Point[end - start + 1];

            for (int i = 0; i < frame_coord.Length; i++)
                frame_coord[i] = tileset.tile_frame[start + i].Location;

            reset();
        }
Esempio n. 2
0
        // Animation handlers
        public void add_animation(string name, TilesetAnimationMode mode, int start, int end, int delay)
        {
            if (start < 0) throw new ArgumentOutOfRangeException("start", "Error in Tileset.add_animation: The animation's starting index was specified as " + start + ".");
            else if (end < 0) throw new ArgumentOutOfRangeException("end", "Error in Tileset.add_animation: The animation's ending index (" + end + ") is less than its starting index (" + start + ").");
            if (delay < 0) throw new ArgumentOutOfRangeException("delay", "Error in Tileset.add_animation: The animation's frame delay was specified as " + delay + ".");

            if (_num_animations >= animations.Length) { // Outgrown the original array. Copy to a larger one.
                TileAnimation[] new_array = new TileAnimation[animations.Length * 2];
                animations.CopyTo(new_array, 0);
                animations = new_array;
            }
            animations[_num_animations] = new TileAnimation(name, mode, start, end, delay, this);
            _num_animations++;
        }