MrGravity.AnimatedSprite.Load C# (CSharp) Méthode

Load() public méthode

Loads function - self explanatory
public Load ( Microsoft.Xna.Framework.Content.ContentManager content, string name, int frameCount, float fps ) : void
content Microsoft.Xna.Framework.Content.ContentManager The current content manager
name string Name of the asset - assumes the animatedSprites folder
frameCount int number of frames
fps float Frames Per Second
Résultat void
        public void Load(ContentManager content, string name, int frameCount, float fps)
        {
            LastFrame = frameCount;
            _mTexture = content.Load<Texture2D>("Images/AnimatedSprites/" + name);
            _mFps = fps;
            Frame = 0;
            _mElapsed = 0.0f;
        }

Usage Example

Exemple #1
0
        /// <summary>
        /// Returns the proper animation for the given tile
        /// </summary>
        /// <param name="name">Name of the tile that needs to be animated</param>
        /// <returns></returns>
        private AnimatedSprite GetAnimation(string name)
        {
            var concatName = name.Substring(name.LastIndexOf('\\') + 1);
            var newAnimation = new AnimatedSprite();

            _wallEngine.ColorScheme = concatName;

            switch (concatName)
            {
                case "Green":
                    if(_mUseVert)
                        newAnimation.Load(_mContent, "GreenVert", 4, 0.15f);
                    else newAnimation.Load(_mContent, "GreenHor", 4, 0.15f);
                    _mUseVert = !_mUseVert;
                    break;
                case "Pink":
                    if(_mUseVert)
                        newAnimation.Load(_mContent, "PinkVert", 4, 0.15f);
                    else newAnimation.Load(_mContent, "PinkHor", 4, 0.15f);
                    _mUseVert = !_mUseVert;
                    break;
                case "Blue":
                    if(_mUseVert)
                        newAnimation.Load(_mContent, "BlueVert", 4, 0.15f);
                    else newAnimation.Load(_mContent, "BlueHor", 4, 0.15f);
                    _mUseVert = !_mUseVert;
                    break;
                case "Yellow":
                    if(_mUseVert)
                        newAnimation.Load(_mContent, "YellowVert", 4, 0.15f);
                    else newAnimation.Load(_mContent, "YellowHor", 4, 0.15f);
                    _mUseVert = !_mUseVert;
                    break;
                case "Purple":
                    if(_mUseVert)
                        newAnimation.Load(_mContent, "PurpleVert", 4, 0.15f);
                    else newAnimation.Load(_mContent, "PurpleHor", 4, 0.15f);
                    _mUseVert = !_mUseVert;
                    break;
                case "Orange":
                    if(_mUseVert)
                        newAnimation.Load(_mContent, "OrangeVert", 4, 0.15f);
                    else newAnimation.Load(_mContent, "OrangeHor", 4, 0.15f);
                    _mUseVert = !_mUseVert;
                    break;
                case "GreenDiamond":
                    newAnimation.Load(_mContent, "GreenDiamond", 3, 0.225f);
                    break;
                case "BlueDiamond":
                    newAnimation.Load(_mContent, "BlueDiamond", 3, 0.225f);
                    break;
                case "OrangeDiamond":
                    newAnimation.Load(_mContent, "OrangeDiamond", 3, 0.225f);
                    break;
                case "PinkDiamond":
                    newAnimation.Load(_mContent, "PinkDiamond", 3, 0.225f);
                    break;
                case "PurpleDiamond":
                    newAnimation.Load(_mContent, "PurpleDiamond", 3, 0.225f);
                    break;
                case "YellowDiamond":
                    newAnimation.Load(_mContent, "YellowDiamond", 3, 0.225f);
                    break;
                case "BlueGem":
                    newAnimation.Load(_mContent, "BlueGem", 6, 0.15f);
                    break;
                case "OrangeGem":
                    newAnimation.Load(_mContent, "OrangeGem", 6, 0.15f);
                    break;
                case "PinkGem":
                    newAnimation.Load(_mContent, "PinkGem", 6, 0.15f);
                    break;
                case "PurpleGem":
                    newAnimation.Load(_mContent, "PurpleGem", 6, 0.15f);
                    break;
                case "GreenGem":
                    newAnimation.Load(_mContent, "GreenGem", 6, 0.15f);
                    break;
                case "YellowGem":
                    newAnimation.Load(_mContent, "YellowGem", 6, 0.15f);
                    break;
                case "MovingHazard":
                    newAnimation.Load(_mContent, "MovingHazard", 4, 0.15f);
                    break;
                case "ReverseMovingHazard":
                    newAnimation.Load(_mContent, "ReverseMovingHazard", 4, 0.15f);
                    break;
                default:
                    newAnimation.Load(_mContent, "NoAnimation", 1, 0.5f);
                    break;
            }
            return newAnimation;
        }