当前位置: 首页>>代码示例>>C#>>正文


C# Animation.Initialize方法代码示例

本文整理汇总了C#中Animation.Initialize方法的典型用法代码示例。如果您正苦于以下问题:C# Animation.Initialize方法的具体用法?C# Animation.Initialize怎么用?C# Animation.Initialize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Animation的用法示例。


在下文中一共展示了Animation.Initialize方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AddLaser

        /// <summary>
        /// Add a laser on the screen
        /// </summary>
        private void AddLaser()
        {
            Animation laserAnimation = new Animation();

            //initialize animation
            laserAnimation.Initialize(
                laserTexture,
                player.Position,
                46, 16,
                1,
                30,
                Color.White,
                1f,
                true);

            //Get player position and offset with cannon image position
            Vector2 laserPosition = player.Position;
            laserPosition.X += 37;

            //Initialize the laser and add it to the list
            Laser laser = new Laser();
            laser.Initialize(laserAnimation, laserPosition);
            laserBeams.Add(laser);
        }
开发者ID:ElementZn,项目名称:ship-game,代码行数:27,代码来源:Game1.cs

示例2: AddExplosion

 private void AddExplosion(Vector2 position)
 {
     Animation explosion = new Animation();
     explosion.Initialize(
         explosionTexture,
         position,
         134, 134, 12, 45,
         Color.White,
         1f,
         false);
     explosions.Add(explosion);
 }
开发者ID:Vintharas,项目名称:Test-projects,代码行数:12,代码来源:Game1.cs

示例3: AddEnemy

        /// <summary>
        /// Spawn enemy on the level
        /// </summary>
        private void AddEnemy()
        {
            //Create the animation object
            Animation enemyAnimation = new Animation();

            //Initialize the animation
            enemyAnimation.Initialize(
                enemyTexture,
                Vector2.Zero,
                47, 61,
                8,
                30,
                Color.White,
                1f,
                true);

            //Generate random enemy position
            Vector2 position = new Vector2(
                GraphicsDevice.Viewport.Width + enemyTexture.Width / 2,
                random.Next(100, GraphicsDevice.Viewport.Height - 100));

            //Create enemy and add to the enemy list
            Enemy enemy = new Enemy();
            enemy.Initialize(enemyAnimation, position);
            enemies.Add(enemy);
        }
开发者ID:ElementZn,项目名称:ship-game,代码行数:29,代码来源:Game1.cs

示例4: AddExplosion

        /// <summary>
        /// Add explosion to dead enemy
        /// </summary>
        /// <param name="enemyPosition">Position of the enemy at death time</param>
        private void AddExplosion(Vector2 enemyPosition)
        {
            //
            Animation explosionAnimation = new Animation();
            explosionAnimation.Initialize(
                explosionTexture,
                enemyPosition,
                134, 134,
                12,
                30,
                Color.White,
                1f,
                true);

            Explosion explosion = new Explosion();
            explosion.Initialize(explosionAnimation, enemyPosition);
            explosions.Add(explosion);
        }
开发者ID:ElementZn,项目名称:ship-game,代码行数:22,代码来源:Game1.cs

示例5: LoadContent

        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            // TODO: use this.Content to load your game content here

            //Fullscreen logic - fuck logic
            #if WINDOWS || LINUX
            Window.IsBorderless = true;
            Window.Position = new Point(0, 0);
            graphics.PreferredBackBufferHeight = GraphicsDevice.DisplayMode.Height;
            graphics.PreferredBackBufferWidth = GraphicsDevice.DisplayMode.Width;
            graphics.ApplyChanges();
            #endif
            //Set the background parameters
            rectBackground = new Rectangle(
                0,
                0,
                GraphicsDevice.Viewport.Width,
                GraphicsDevice.Viewport.Height);
            bgLayer1 = new ParallaxingBackground();
            bgLayer2 = new ParallaxingBackground();

            //Load the menu textures
            Texture2D menuBackground = Content.Load<Texture2D>("Graphics\\mainMenu");
            mainMenu = new Menu(menuBackground);
            Texture2D gameOverBackground = Content.Load<Texture2D>("Graphics\\endMenu");
            gameOverMenu = new Menu(gameOverBackground);
            gameOverMenu.Active = false;

            //Assign buttons to the menus
            ButtonAction btnAction;
            btnAction = NewGame;
            mainMenu.AddButton("New Game", btnAction);
            gameOverMenu.AddButton("Try Again", btnAction);
            btnAction = HighScores;
            mainMenu.AddButton("High Scores", btnAction);
            #if WINDOWS || LINUX
            btnAction = QuitGame;
            mainMenu.AddButton("Quit", btnAction);
            gameOverMenu.AddButton("Quit", btnAction);
            #endif
            //Load the game over menu

            //Load the font
            spriteFont = Content.Load<SpriteFont>("Graphics\\gameFont");

            //Load the player resources
            Animation playerAnimation = new Animation();
            Texture2D playerTexture = Content.Load<Texture2D>("Graphics\\shipAnimation");
            playerAnimation.Initialize(playerTexture, Vector2.Zero, 115, 69, 8, 30, Color.White, 1f, true);
            playerPosition = new Vector2(
                GraphicsDevice.Viewport.TitleSafeArea.X + GraphicsDevice.Viewport.TitleSafeArea.Width / 2,
                GraphicsDevice.Viewport.TitleSafeArea.Y + GraphicsDevice.Viewport.TitleSafeArea.Height / 2
                );
            player.Initialize(playerAnimation, playerPosition);

            //Load the parallaxing background
            bgLayer1.Initialize(
                Content, "Graphics\\bgLayer1",
                GraphicsDevice.Viewport.Width,
                GraphicsDevice.Viewport.Height,
                (int)-scale);
            bgLayer2.Initialize(
                Content, "Graphics\\bgLayer2",
                GraphicsDevice.Viewport.Width,
                GraphicsDevice.Viewport.Height,
                (int)-scale * 2);
            mainBackground = Content.Load<Texture2D>("Graphics\\mainbackground");

            //Load enemy graphics
            enemyTexture = Content.Load<Texture2D>("Graphics\\mineAnimation");

            //Load laser textures
            laserTexture = Content.Load<Texture2D>("Graphics\\laser");

            //Load explosions
            explosionTexture = Content.Load<Texture2D>("Graphics\\explosion");
        }
开发者ID:ElementZn,项目名称:ship-game,代码行数:84,代码来源:Game1.cs

示例6: AddEnemy

        private void AddEnemy()
        {
            Animation enemyAnimation = new Animation();
            enemyAnimation.Initialize(enemyTexture, Vector2.Zero, 47, 61, 8, 30, Color.White, 1f, true);

            Vector2 position = new Vector2(GraphicsDevice.Viewport.Width + enemyTexture.Width / 2, random.Next(100, GraphicsDevice.Viewport.Height - 100));

            Enemy enemy = new Enemy();
            enemy.Initialize(enemyAnimation, position);
            enemies.Add(enemy);
        }
开发者ID:urvaius,项目名称:Win8ShooterGame,代码行数:11,代码来源:Game1.cs

示例7: LoadContent

        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            _spriteBatch = new SpriteBatch(GraphicsDevice);
            // Load the player resources

            Rectangle titleSafeArea = GraphicsDevice.Viewport.TitleSafeArea;
            var playerPosition = new Vector2(titleSafeArea.X, titleSafeArea.Y + titleSafeArea.Height / 2);

            Texture2D playerTexture = Content.Load<Texture2D>(@"Graphics\shipAnimation");
            Animation playerAnimation = new Animation();
            playerAnimation.Initialize(playerTexture,playerPosition ,115,69,8,30,Color.White,1f,true);

            bgLayer1.Initialize(Content, @"Graphics\bgLayer1", GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height, -1);

            bgLayer2.Initialize(Content, @"Graphics\bgLayer2", GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height, -2);

            mainBackground = Content.Load<Texture2D>(@"Graphics\mainbackground");
            //Vector2 playerPosition = new Vector2(GraphicsDevice.Viewport.TitleSafeArea.X, GraphicsDevice.Viewport.TitleSafeArea.Y + GraphicsDevice.Viewport.TitleSafeArea.Height / 2);

            enemyTexture = Content.Load<Texture2D>(@"Graphics\mineAnimation");
            player.Initialize(playerAnimation,playerPosition);

            //player.Initialize(Content.Load<Texture2D>("Graphics\\player"), playerPosition);
            // TODO: use this.Content to load your game content here
        }
开发者ID:urvaius,项目名称:Win8ShooterGame,代码行数:30,代码来源:Game1.cs

示例8: AttachAnimation

        public void AttachAnimation(Sprite sprite, Animation animation, params ActiveAnimationSetUpdater[] animationUpdaters)
        {
            animation.Initialize(this, sprite);

            foreach (var animationUpdater in animationUpdaters)
            {
                animationUpdater.Add(animation);
            }

            Animation activeAnimation = sprite.ActiveAnimation;

            if (activeAnimation == null)
            {
                sprite.ActiveAnimation = animation;
                this.animations.Add(animation);
            }
            else
            {
                while (activeAnimation.NextAnimation != null)
                {
                    activeAnimation = activeAnimation.NextAnimation;

                    if (activeAnimation == animation)
                        throw new ArgumentException("Same animation attached more than once");
                }

                activeAnimation.NextAnimation = animation;
            }
        }
开发者ID:jlyonsmith,项目名称:ToyBox,代码行数:29,代码来源:SpriteManager.cs

示例9: AnimationForFrameNames

        /* ***********************************
         * Methods Relating to Animation
         * 
         *************************************/


        /*
         * Create animation object from sprite sheet and frame names.
         * 
         * 
         */

        public Animation AnimationForFrameNames(String[] frameNames, int frameTime, Color frameColor, bool isLooping)
        {
            // create animation object.
            Animation animation = new Animation();
            // create frames array.
            Frame[] frames = new Frame[frameNames.Length];

            // loop through frameNames and poplulate Frame array.
            for ( int i = 0; i < frameNames.Length; i++ )
            {
                frames[i] = SpriteFrameByFrameName(frameNames[i]);   
            }

            // initialize animation and return.
            animation.Initialize(_texture, frames, frameTime, frameColor, isLooping);
            return animation;
        }
开发者ID:AJSchultheis,项目名称:Dream.Build.Play.2012,代码行数:29,代码来源:SpriteSheet.cs


注:本文中的Animation.Initialize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。