예제 #1
0
        public void play(String AnimName, Boolean Force = false)
        {
            if (!Force && (_curAnim != null) && (AnimName == _curAnim.name) && (_curAnim.looped || !finished))
            {
                return;
            }
            _curFrame   = 0;
            _curIndex   = 0;
            _frameTimer = 0;
            uint i = 0;
            uint l = (uint)_animations.Count;

            while (i < l)
            {
                if (_animations[(int)i].name == AnimName)
                {
                    _curAnim = _animations[(int)i];
                    if (_curAnim.delay <= 0)
                    {
                        finished = true;
                    }
                    else
                    {
                        finished = false;
                    }
                    _curIndex = _curAnim.frames[_curFrame];
                    dirty     = true;
                    return;
                }
                i++;
            }
            FlxG.log("WARNING: No animation called \"" + AnimName + "\"");
        }
예제 #2
0
        public FlxSprite(float X = 0, float Y = 0, Texture2D Graphic = null)
            : base(X, Y)
        {
            scale = new FlxPoint(1.0f, 1.0f);
            offset = new FlxPoint();
            origin = new FlxPoint();
            alpha = 1.0f;
            _color = Color.White * alpha;

            _animations = new List<FlxAnim>();
            _animated = false;

            finished = false;
            _facing = RIGHT;
            _flipped = 0;
            _curAnim = null;
            _curFrame = 0;
            _curIndex = 0;
            _frameTimer = 0;

            _callback = null;
            _matrix = new Matrix();

            if (Graphic == null)
                Graphic = ImgDefault;
            loadGraphic(Graphic);

            angle = 0f;

            camX = camY = 0;
            oX = X;
            oY = Y;

            moving = false;
        }
예제 #3
0
        public FlxSprite(float X = 0, float Y = 0, Texture2D Graphic = null)
            : base(X, Y)
        {
            scale  = new FlxPoint(1.0f, 1.0f);
            offset = new FlxPoint();
            origin = new FlxPoint();
            alpha  = 1.0f;
            _color = Color.White * alpha;

            _animations = new List <FlxAnim>();
            _animated   = false;

            finished    = false;
            _facing     = RIGHT;
            _flipped    = 0;
            _curAnim    = null;
            _curFrame   = 0;
            _curIndex   = 0;
            _frameTimer = 0;

            _callback = null;
            _matrix   = new Matrix();

            if (Graphic == null)
            {
                Graphic = ImgDefault;
            }
            loadGraphic(Graphic);

            angle = 0f;

            camX = camY = 0;
            oX   = X;
            oY   = Y;

            moving = false;
        }
예제 #4
0
        public override void destroy()
        {
            if (_animations != null)
            {
                FlxAnim a;
                int     i = 0;
                int     l = _animations.Count;
                while (i < l)
                {
                    a = _animations[i++];
                    if (a != null)
                    {
                        a.destroy();
                    }
                }
                _animations = null;
            }

            offset    = null;
            origin    = null;
            scale     = null;
            _curAnim  = null;
            _callback = null;
        }
예제 #5
0
 public void play(String AnimName, Boolean Force=false)
 {
     if (!Force && (_curAnim != null) && (AnimName == _curAnim.name) && (_curAnim.looped || !finished)) return;
     _curFrame = 0;
     _curIndex = 0;
     _frameTimer = 0;
     uint i = 0;
     uint l = (uint)_animations.Count;
     while(i < l)
     {
         if(_animations[(int)i].name == AnimName)
         {
             _curAnim = _animations[(int)i];
             if(_curAnim.delay <= 0)
                 finished = true;
             else
                 finished = false;
             _curIndex = _curAnim.frames[_curFrame];
             dirty = true;
             return;
         }
         i++;
     }
     FlxG.log("WARNING: No animation called \""+AnimName+"\"");
 }
예제 #6
0
        public override void destroy()
        {
            if(_animations != null)
            {
                FlxAnim a;
                int i = 0;
                int l = _animations.Count;
                while(i < l)
                {
                    a = _animations[i++];
                    if(a != null)
                        a.destroy();
                }
                _animations = null;
            }

            offset = null;
            origin = null;
            scale = null;
            _curAnim = null;
            _callback = null;
        }
예제 #7
0
 public void randomFrame()
 {
     _curAnim = null;
     _curIndex = (int)(FlxG.random() * (texture.Width / frameWidth));
     dirty = true;
 }