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


C# Sprite.Initialize方法代碼示例

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


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

示例1: Initialize

        /// <summary>
        /// Allows the app 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()
        {
            // TODO: Add your initialization logic here

            IsMouseVisible = true; // easier for debugging not to "lose" mouse
            SetWindowOnSurface();
            InitializeSurfaceInput();

            // Set the application's orientation based on the orientation at launch
            currentOrientation = ApplicationServices.InitialOrientation;

            // Subscribe to surface window availability events
            ApplicationServices.WindowInteractive += OnWindowInteractive;
            ApplicationServices.WindowNoninteractive += OnWindowNoninteractive;
            ApplicationServices.WindowUnavailable += OnWindowUnavailable;

            // Setup the UI to transform if the UI is rotated.
            // Create a rotation matrix to orient the screen so it is viewed correctly
            // when the user orientation is 180 degress different.
            Matrix inverted = Matrix.CreateRotationZ(MathHelper.ToRadians(180)) *
                        Matrix.CreateTranslation(graphics.GraphicsDevice.Viewport.Width,
                                                    graphics.GraphicsDevice.Viewport.Height,
                                                    0);

            if (currentOrientation == UserOrientation.Top)
            {
                screenTransform = inverted;
            }

            screenWidth = Program.WindowSize.Width;
            screenHeight = Program.WindowSize.Height;

            manager = new Manager();
            manager.Initialize(this, touchTarget, Manager.SelectionMode.MONO);
            manager.Behaviour = new BehaviourPlane(screenWidth, screenHeight, _serverIP);

            aircraftCarrier = new Sprite("aircraftCarrier", "aircraftCarrier");
            aircraftCarrier.Initialize(touchTarget);
            aircraftCarrier.Touchable = false;
            manager.Register(aircraftCarrier);

            plane1 = new enib.pa.Plane("plane1");
            plane1.Initialize(touchTarget);
            plane1.Scale = 0.13f;
            plane1.Weight = 1;
            plane1.Rotation = -(float)0;
            plane1.ShowBoundingRect = true;
            plane1.Dragable = false;
            manager.Register(plane1);

            plane2 = new enib.pa.Plane("plane2");
            plane2.Initialize(touchTarget);
            plane2.Scale = 0.13f;
            plane2.Weight = 1;
            plane2.Rotation = (float)Math.PI /2;
            plane2.ShowBoundingRect = true;
            plane2.Dragable = false;
            manager.Register(plane2);

            plane3 = new enib.pa.Plane("plane3");
            plane3.Initialize(touchTarget);
            plane3.Scale = 0.13f;
            plane3.Weight = 1;
            plane3.Rotation = (float)Math.PI;
            plane3.ShowBoundingRect = true;
            plane3.Dragable = false;
            manager.Register(plane3);

            plane4 = new enib.pa.Plane("plane4");
            plane4.Initialize(touchTarget);
            plane4.Scale = 0.13f;
            plane4.Weight = 1;
            plane4.Rotation = -(float)Math.PI / 2;
            plane4.ShowBoundingRect = true;
            plane4.Dragable = false;
            manager.Register(plane4);

            menu_pt1 = new Plane_Menu_Elevator("ascenseur1");
            menu_pt1.setPlaneur(plane1);

            menu_pt2 = new Plane_Menu_Catapulte1("catapulte1");
            menu_pt2.setPlaneur(plane1);

            menu_pt3 = new Plane_Menu_Catapulte2("catapulte2");
            menu_pt3.setPlaneur(plane1);

            menu = new Enib.SurfaceLib.Menu(manager, plane1);
            menu.Initialize(touchTarget);
            menu.addMenuEntry(menu_pt1);
            menu.addMenuEntry(menu_pt2);
            menu.addMenuEntry(menu_pt3);
            menu.Hide();

            base.Initialize();
//.........這裏部分代碼省略.........
開發者ID:PixelSenseEnib,項目名稱:PixelSense,代碼行數:101,代碼來源:App1.cs

示例2: Initialize

        /// <summary>
        /// Allows the app 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()
        {
            // TODO: Add your initialization logic here

            IsMouseVisible = true; // easier for debugging not to "lose" mouse
            SetWindowOnSurface();
            InitializeSurfaceInput();

            // Set the application's orientation based on the orientation at launch
            currentOrientation = ApplicationServices.InitialOrientation;

            // Subscribe to surface window availability events
            ApplicationServices.WindowInteractive += OnWindowInteractive;
            ApplicationServices.WindowNoninteractive += OnWindowNoninteractive;
            ApplicationServices.WindowUnavailable += OnWindowUnavailable;

            // Setup the UI to transform if the UI is rotated.
            // Create a rotation matrix to orient the screen so it is viewed correctly
            // when the user orientation is 180 degress different.
            Matrix inverted = Matrix.CreateRotationZ(MathHelper.ToRadians(180)) *
                       Matrix.CreateTranslation(graphics.GraphicsDevice.Viewport.Width,
                                                 graphics.GraphicsDevice.Viewport.Height,
                                                 0);

            if (currentOrientation == UserOrientation.Top)
            {
                screenTransform = inverted;
            }

            screenWidth = Program.WindowSize.Width;
            screenHeight = Program.WindowSize.Height;

            manager = new Manager();
            manager.Behaviour = new Behaviour(screenWidth, screenHeight);
            manager.Initialize(this, touchTarget, Manager.SelectionMode.NONE);

            batLeft = new Sprite("raquette1", "raquette1");
            batLeft.Initialize(touchTarget);
            batLeft.Weight = 1;
            manager.register(batLeft);

            batRight = new Sprite("raquette2", "raquette2");
            batRight.Initialize(touchTarget);
            batRight.Weight = 1;
            batRight.Position = new Vector2(screenWidth - 140, screenHeight - 455);
            manager.register(batRight);

            bignou = new Sprite("bignou", "paletGame");
            bignou.Initialize(touchTarget);
            bignou.Position = new Vector2((screenWidth - 250) / 2, (screenHeight - 250) / 2);
            manager.register(bignou);

            base.Initialize();
        }
開發者ID:PixelSenseEnib,項目名稱:PixelSense,代碼行數:60,代碼來源:App1.cs


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