public int PlayAnimation(string pAnimationName, FramedSprite pSprite)
        {
            if (animations.ContainsKey(pAnimationName))
            {
                AnimationJob job = new AnimationJob {
                    Sprite          = pSprite,
                    Tokens          = animations[pAnimationName],
                    State           = AnimationState.Running,
                    CurrentStep     = 0,
                    ElapsedMsInStep = 0
                };

                animationId++;

                if (animationId == int.MaxValue)
                {
                    animationId = 0;
                }

                jobs.Add(animationId, job);
                return(animationId);
            }

            throw new Exception("Animation '" + pAnimationName + "' does not exist.");
        }
Ejemplo n.º 2
0
        public Font(FramedSprite pSprite, Dictionary <int, int> pMapping, int pHorizontalSpace, int pVerticalSpace, Color pFontColor)
        {
            sprite = pSprite;
            sprite.SetCurrentFrame(0);
            sprite.SetTint(pFontColor);

            mapping = pMapping;

            spacing = new Size {
                Width = pHorizontalSpace, Height = pVerticalSpace
            };
        }
        public override void LoadContent(ContentManager pContentManager)
        {
            base.LoadContent(pContentManager);

            spaceIslandTexture = pContentManager.GetTexture("Content/Sprites/space-island.png");
            Texture2D tinyMaleTexture = pContentManager.GetTexture("Content/Sprites/tiny-male.png");

            tinyMaleSprite = new FramedSprite(8, 4, 0, tinyMaleTexture, new Vector2(100, 100), Color.White);

            Texture2D    fontSpriteTexture = pContentManager.GetTexture("Content/Fonts/small-font.png");
            FramedSprite fontSprite        = new FramedSprite(8, 6, 0, fontSpriteTexture, Vector2.Zero, Color.White);

            var mapping = pContentManager.GetFontMapping("Content/Fonts/small-font.fontmapping");

            smallFont = new Font(fontSprite, mapping, 0, 1, Color.PowderBlue);
        }
Ejemplo n.º 4
0
        public override void LoadContent(ContentManager pContentManager)
        {
            base.LoadContent(pContentManager);

            spaceIslandTexture = pContentManager.GetTexture("Content/Sprites/space-island.png");
            Texture2D tinyMaleTexture = pContentManager.GetTexture("Content/Sprites/tiny-male.png");

            tinyMaleSprite = new Sprite(tinyMaleTexture, new Vector2(100, 100), Color.White, 4f);
            Texture2D evilTinyMaleTexture = pContentManager.GetTexture("Content/Sprites/evil-tiny-male.png");

            evilTinyMaleSprite = new Sprite(evilTinyMaleTexture, new Vector2(300, 100), Color.White, 4f);

            Texture2D    fontSpriteTexture = pContentManager.GetTexture("Content/Fonts/small-font.png");
            FramedSprite fontSprite        = new FramedSprite(8, 6, 0, fontSpriteTexture, Vector2.Zero, Color.White, 8f);

            var mapping = pContentManager.GetFontMapping("Content/Fonts/small-font.fontmapping");

            smallFont = new Font(fontSprite, mapping, 0, 1, Color.SeaGreen);

            //Scrolling Background - simple
            backgroundTexture         = pContentManager.GetTexture("Content/Sprites/seamless_flame.jpg");
            backgroundTexture_TileOne = new Sprite(backgroundTexture, Vector2.Zero, Color.White, 1f);
            backgroungTexture_TileTwo = new Sprite(backgroundTexture, new Vector2(backgroundTexture.Width, 0), Color.White, 1f);
        }