示例#1
0
        public PlayerOne(TextureManager _t, Renderer renderer)
        {
            this.renderer = renderer;
            Width         = 32;
            Height        = 48;

            position = new Vector2D(0, 50);

            //Texture texture = _t.Get("Player00");
            //sprite = new Sprite();
            //sprite.Texture = texture;
            //sprite.SetWidth(Width);
            //sprite.SetHeight(Height);
            //sprite.SetPosition(position.X, position.Y);
            //multiSprite = new MultiSprite(sprite);
            //RecTangleF[] rects = new RecTangleF[8];
            //for (int i = 0; i < 8;i++ )
            //    rects[i] = new RecTangleF(0 + i * 4 * per_256, 0, 4 * per_256 + i * 4 * per_256, 6 * per_256);
            //multiSprite.RegeditState(0, rects);      //将此rectangleF注册到0号state
            //multiSprite.State = 0;                   //将状态切换为0号state

            Texture texture = _t.Get("Player2");

            sprite         = new Sprite();
            sprite.Texture = texture;
            sprite.SetWidth(Width);
            sprite.SetHeight(Height);
            sprite.SetPosition(position.X, position.Y);
            multiSprite = new MultiSprite(sprite);

            RecTangleF[] rects = new RecTangleF[4];
            for (int i = 0; i < 4; i++)
            {
                rects[i] = new RecTangleF(0 + i * 4 * per_256, 0, 4 * per_256 + i * 4 * per_256, 6 * per_256);
            }
            multiSprite.RegeditState(0, rects);      //将此rectangleF注册到0号state

            rects = new RecTangleF[3];
            for (int i = 0; i < 3; i++)
            {
                rects[i] = new RecTangleF(i * 4 * per_256, 6 * per_256,
                                          4 * per_256 + i * 4 * per_256, 12 * per_256);
            }
            multiSprite.RegeditState(1, rects);      //将此rectangleF注册到1号state (过渡移动)

            rects = new RecTangleF[4];
            for (int i = 0; i < 4; i++)
            {
                rects[i] = new RecTangleF(12 * per_256 + i * 4 * per_256, 6 * per_256,
                                          12 * per_256 + 4 * per_256 + i * 4 * per_256, 12 * per_256);
            }
            multiSprite.RegeditState(2, rects);      //将此rectangleF注册到2号state (移动)

            rects = new RecTangleF[3];
            for (int i = 0; i < 3; i++)
            {
                rects[i] = new RecTangleF(4 * per_256 + i * 4 * per_256, 6 * per_256,
                                          i * 4 * per_256, 12 * per_256);
            }
            multiSprite.RegeditState(3, rects);      //将此rectangleF注册到3号state (过渡移动,右)

            rects = new RecTangleF[4];
            for (int i = 0; i < 4; i++)
            {
                rects[i] = new RecTangleF(12 * per_256 + 4 * per_256 + i * 4 * per_256, 6 * per_256,
                                          12 * per_256 + i * 4 * per_256, 12 * per_256);
            }
            multiSprite.RegeditState(4, rects);      //将此rectangleF注册到4号state (移动)

            multiSprite.RegeditCollection(1, 2);     //将1号动画连接到2号动画上
            multiSprite.RegeditCollection(3, 4);     //将3号动画连接到4号动画上
            multiSprite.State = 1;                   //将状态切换为1号state
        }
示例#2
0
        public PlayerOne(TextureManager _t , Renderer renderer)
        {
            this.renderer = renderer;
            Width = 32;
            Height = 48;

            position = new Vector2D(0, 50);

            //Texture texture = _t.Get("Player00");
            //sprite = new Sprite();
            //sprite.Texture = texture;
            //sprite.SetWidth(Width);
            //sprite.SetHeight(Height);
            //sprite.SetPosition(position.X, position.Y);
            //multiSprite = new MultiSprite(sprite);
            //RecTangleF[] rects = new RecTangleF[8];
            //for (int i = 0; i < 8;i++ )
            //    rects[i] = new RecTangleF(0 + i * 4 * per_256, 0, 4 * per_256 + i * 4 * per_256, 6 * per_256);
            //multiSprite.RegeditState(0, rects);      //将此rectangleF注册到0号state
            //multiSprite.State = 0;                   //将状态切换为0号state

            Texture texture = _t.Get("Player2");
            sprite = new Sprite();
            sprite.Texture = texture;
            sprite.SetWidth(Width);
            sprite.SetHeight(Height);
            sprite.SetPosition(position.X, position.Y);
            multiSprite = new MultiSprite(sprite);

            RecTangleF[] rects = new RecTangleF[4];
            for (int i = 0; i < 4; i++)
                rects[i] = new RecTangleF(0 + i * 4 * per_256, 0, 4 * per_256 + i * 4 * per_256, 6 * per_256);
            multiSprite.RegeditState(0, rects);      //将此rectangleF注册到0号state

            rects = new RecTangleF[3];
            for (int i = 0; i < 3; i++)
                rects[i] = new RecTangleF( i * 4 * per_256, 6 * per_256,
                    4 * per_256 + i * 4 * per_256, 12 * per_256);
            multiSprite.RegeditState(1, rects);      //将此rectangleF注册到1号state (过渡移动)

            rects = new RecTangleF[4];
            for (int i = 0; i < 4; i++)
                rects[i] = new RecTangleF(12*per_256 + i * 4 * per_256, 6*per_256,
                   12*per_256+ 4 * per_256 + i * 4 * per_256, 12 * per_256);
            multiSprite.RegeditState(2, rects);      //将此rectangleF注册到2号state (移动)

            rects = new RecTangleF[3];
            for (int i = 0; i < 3; i++)
                rects[i] = new RecTangleF(4 * per_256 + i * 4 * per_256, 6 * per_256,
                   i * 4 * per_256, 12 * per_256);
            multiSprite.RegeditState(3, rects);      //将此rectangleF注册到3号state (过渡移动,右)

            rects = new RecTangleF[4];
            for (int i = 0; i < 4; i++)
                rects[i] = new RecTangleF(12 * per_256 + 4 * per_256 + i * 4 * per_256, 6 * per_256,
                12 * per_256 + i * 4 * per_256 , 12 * per_256);
            multiSprite.RegeditState(4, rects);      //将此rectangleF注册到4号state (移动)

            multiSprite.RegeditCollection(1, 2);     //将1号动画连接到2号动画上
            multiSprite.RegeditCollection(3, 4);     //将3号动画连接到4号动画上
            multiSprite.State = 1;                   //将状态切换为1号state
        }