当前位置: 首页>>代码示例>>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;未经允许,请勿转载。