Exemplo n.º 1
0
 /// <summary>
 /// Plays an existing animation (e.g. "run").
 /// If you call an animation that is already playing it will be ignored.
 /// </summary>
 /// <param name="AnimName">The string name of the animation you want to play.</param>
 /// <param name="Force">Whether to force the animation to restart.</param>
 public void play(string AnimName, bool Force)
 {
     if (!Force && (_curAnim != null) && (AnimName == _curAnim.name))
     {
         return;
     }
     _curFrame   = 0;
     _caf        = 0;
     _frameTimer = 0;
     for (int i = 0; i < _animations.Count; i++)
     {
         if (_animations[i].name == AnimName)
         {
             _curAnim = _animations[i];
             if (_curAnim.delay <= 0)
             {
                 finished = true;
             }
             else
             {
                 finished = false;
             }
             _caf = _curAnim.frames[_curFrame];
             calcFrame();
             return;
         }
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// FlxSprite private constructor
        /// </summary>
        /// <param name="X"></param>
        /// <param name="Y"></param>
        /// <param name="SimpleGraphic"></param>
        private void constructor(float X, float Y, Texture2D SimpleGraphic)
        {
            x = X;
            y = Y;

            originalPosition.X = X;
            originalPosition.Y = Y;

            _flashRect      = new Rectangle();
            _flashRect2     = new Rectangle();
            _flashPointZero = new Point();
            offset          = new Point();

            scale        = 1f;
            _alpha       = 1;
            _color       = Color.White;
            _lastColor   = Color.White;
            blend        = null;
            antialiasing = false;

            finished            = false;
            facing              = Flx2DFacing.NotUsed;
            _animations         = new List <FlxAnim>();
            _flipped            = 0;
            _curAnim            = null;
            _curFrame           = 0;
            _caf                = 0;
            _frameTimer         = 0;
            boundingBoxOverride = true;

            _colorFlicker      = false;
            _colorFlickerTimer = -1;

            //_mtx = new Matrix();
            _callback = null;
            //if (_gfxSprite == null)
            //{
            //    _gfxSprite = new Sprite();
            //    _gfx = _gfxSprite.graphics;
            //}

            if (SimpleGraphic == null)
            {
                createGraphic(8, 8, color);
            }
            else
            {
                loadGraphic(SimpleGraphic);
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// Tell the sprite to change to a random frame of animation
 /// Useful for instantiating particles or other weird things.
 /// </summary>
 public void randomFrame()
 {
     _curAnim = null;
     _caf     = (int)(FlxU.random() * (_tex.Width / frameWidth));
     calcFrame();
 }