Exemplo n.º 1
0
        /// <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

            Animation playerAnimation = new Animation();
            Texture2D playerTexture = Content.Load<Texture2D>("animations/shipAnimation");

            playerAnimation.Initialize( playerTexture, Vector2.Zero, 115, 69, 8, 30, Color.White, 1f, true );

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

            player.Initialize(playerAnimation, playerPosition);

            //player.Initialize(Content.Load<Texture2D>("player"), playerPosition);
        }
        /* ***********************************
         * 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;
        }