當前位置: 首頁>>代碼示例>>C#>>正文


C# Ball.placeInDefaultPosition方法代碼示例

本文整理匯總了C#中Ball.placeInDefaultPosition方法的典型用法代碼示例。如果您正苦於以下問題:C# Ball.placeInDefaultPosition方法的具體用法?C# Ball.placeInDefaultPosition怎麽用?C# Ball.placeInDefaultPosition使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Ball的用法示例。


在下文中一共展示了Ball.placeInDefaultPosition方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Initialize

        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);
            // Publish the service, allowing everything to use the spriteBatch
            Services.AddService(typeof(SpriteBatch), spriteBatch);

            // Player classes.
            player1 = new Player(this, Pallet.PlayerNumber.PlayerOne);
            player1.Name = "Player 1";
            player2 = new Player(this, Pallet.PlayerNumber.PlayerTwo);
            player2.Name = "Player 2";

            // Ball classes.
            ball = new Ball(this);

            // Collision groups
            collisionGroup = new Group("Collisions");
            playerGroup = new Group("Players");

            playerGroup.Add(player1.Pallet);
            playerGroup.Add(player2.Pallet);

            // Groups
            GroupList GameGroups = new GroupList();
            GameGroups.Add(collisionGroup);
            GameGroups.Add(playerGroup);
            //Add the list of groups into the services so objects can retrieve info about items in specific groups
            Services.AddService(typeof(GroupList), GameGroups);

            // Blocks
            BlockList = new BlockManager(this);

            // Will initialize the basic graphical objects.
            base.Initialize(); // Goes to LoadContent()

            // Placed after general initialisation so the texture is already loaded and its size initialized
            player1.Pallet.placeInDefaultPosition();
            player2.Pallet.placeInDefaultPosition();

            /* Define the block safe zone, it's meant to restrict where the blocks can appear so they don't get on top of the pallet
             * or behind it. */
            BlockList.BlocksSafeZone = new Rectangle((int)player1.Pallet.Position.X + 1, 0,
                (int)player2.Pallet.Position.X + (int)player2.Pallet.ObjectRectangle.Width - (int)player1.Pallet.ObjectRectangle.X - BlockList.MaxBlockSize,
                Window.ClientBounds.Height - BlockList.MaxBlockSize);

            // Places the ball in the center position and give it a random angle.
            ball.placeInDefaultPosition();
        }
開發者ID:kratosaurion7,項目名稱:Pung,代碼行數:55,代碼來源:PungGame.cs


注:本文中的Ball.placeInDefaultPosition方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。