Ejemplo n.º 1
0
 public Animation(GameObject parent, int width, int height, bool useTimer)
 {
     _texture           = parent._texture;
     _textureRect       = new Rectangle(0, 0, _texture.Width, _texture.Height);
     _displayRect       = new Rectangle(0, 0, width, height);
     _cols              = _texture.Width / width;
     _rows              = _texture.Height / height;
     _totalFrames       = _cols * _rows;
     _parent            = parent;
     _currentStage      = new AnimationStage(0, _totalFrames - 1, true, 0, false);
     _parent._srcRect   = _displayRect;
     _currentStageIndex = 0;
     _useTimer          = useTimer;
     if (_useTimer)
     {
         _timer      = new Timer(DEFAULT_FRAME_DELAY, 0, Animate, this);
         _timerIndex = Timers.Add(_timer);
     }
 }
Ejemplo n.º 2
0
 public void Remove()
 {
     Timers.Remove(_timerIndex);
     _parent = null;
 }