コード例 #1
0
        public void createPlayerAttackSpriteSheets(Player player)
        {
            List <Rectangle> sourceBAL = new List <Rectangle>();
            List <Rectangle> sourceBAR = new List <Rectangle>();
            List <Rectangle> sourceBAU = new List <Rectangle>();
            List <Rectangle> sourceBAD = new List <Rectangle>();

            //List<Rectangle> sourceSA = new List<Rectangle>();
            List <Rectangle> collBAL           = new List <Rectangle>();
            List <Rectangle> collBAR           = new List <Rectangle>();
            List <Rectangle> collBAU           = new List <Rectangle>();
            List <Rectangle> collBAD           = new List <Rectangle>();
            Texture2D        attackSpriteSheet = loadImage("TestWorld/TestLevel1/playerAttacksSpriteSheet");
            //List<Rectangle> collSA = new List<Rectangle>();
            //27w28h
            int width  = 27;
            int height = 28;

            for (int r = 0; r < 4; r++)
            {
                for (int c = 0; c < 4; c++)
                {
                    Rectangle source = new Rectangle(c * width, (r * 2) * height, width, height);
                    Rectangle coll   = new Rectangle(c * width, (r + 1) * height, width, height);
                    switch (r)
                    {
                    case 0:
                        sourceBAD.Add(source);
                        collBAD.Add(coll);
                        break;

                    case 1:
                        sourceBAR.Add(source);
                        collBAR.Add(coll);
                        break;

                    case 2:
                        sourceBAL.Add(source);
                        collBAL.Add(coll);
                        break;

                    case 3:
                        sourceBAU.Add(source);
                        collBAU.Add(source);
                        break;
                    }
                }
            }
            Rectangle destination = new Rectangle(player.getXPos(), player.getYPos(), width * Constants.BLOCK_SCALE, height * Constants.BLOCK_SCALE);

            AttackSpriteSheet basicAttackSpriteSheet = new AttackSpriteSheet(sourceBAR, collBAR, destination, attackSpriteSheet, 0, 5, 0);

            basicAttackSpriteSheet.setAttackSpriteSheets(sourceBAU, sourceBAD, sourceBAL, sourceBAR, collBAU, collBAD, collBAR, collBAL);
            player.setAttacksSpriteSheet(basicAttackSpriteSheet, basicAttackSpriteSheet);
        }
コード例 #2
0
 public void setAttacksSpriteSheet(AttackSpriteSheet bA, AttackSpriteSheet sA)
 {
     this.bA = bA;
     this.sA = sA;
 }