Example #1
0
        public HowToPlay(Game game)
            : base(game)
        {
            // Background
            Sprite BluePrintBackground = Graphics.GetSprite("assets/sprites/background_blueprint_tile.png");
            BluePrintBackground.Texture.Repeated = true;
            BluePrintBackground.TextureRect = new IntRect(0, 0, (int)Game.Size.X, (int)Game.Size.Y);
            AddChild(BluePrintBackground);

            // help
            Text help = new Text("(tap to continue)", Game.TidyHand, 30);
            FloatRect textRect = help.GetLocalBounds();
            help.Origin = new Vector2f(textRect.Left + textRect.Width / 2.0f, textRect.Top + textRect.Height / 2.0f);
            help.Position = new Vector2f(Game.Size.X / 2, Game.Size.Y - 25);
            AddChild(help);

            Tutorial = Graphics.GetAnimatedSprite(Game, Graphics.ASSETS_SPRITES + "gui/HowToPlay.xml");
            Tutorial.Sprite.Texture.Smooth = false;
            Tutorial.Stop();
            Tutorial.SetFrame(0);
            AddChild(Tutorial);
        }
Example #2
0
        /// <param name="xml">The XML file for the Animated Sprite.</param>
        public static AnimatedSprite GetAnimatedSprite(Game game, string xml)
        {
            AnimatedSprite sprite = new AnimatedSprite(game, GetAnimatedSpriteData(xml));

            return sprite;
        }
Example #3
0
        /// <param name="xml">The XML file for the Animated Sprite.</param>
        public static AnimatedSprite GetAnimatedSprite(Game game, string xml)
        {
            AnimatedSprite sprite = new AnimatedSprite(game, GetAnimatedSpriteData(xml));

            return(sprite);
        }
        public bool SetFrame(int number)
        {
            if (number >= TotalFrames)
                return false;

            CurrentFrame = number;
            Finished = CurrentFrame == TotalFrames-1;

            if (CurrentNestedAnimatedSprite != null)
            {
                RemoveChild(CurrentNestedAnimatedSprite);
                CurrentNestedAnimatedSprite = null;
            }
            if (Data.Frames[(int)CurrentFrame] is AnimatedSpriteDataReference)
            {
                Model.Visible = false;
                // TODO - instead of re-creating AnimateSprites, loop through Frames and create Array filled with all the Nested AnimatedSprites.
                CurrentNestedAnimatedSprite = new AnimatedSprite(Game, Data.Frames[(int)CurrentFrame].Data);
                CurrentNestedAnimatedSprite.Position = Data.Frames[(int)CurrentFrame].Origin;
                AddChild(CurrentNestedAnimatedSprite);

                return false;
            }
            else
                Model.Visible = true;

            if (Data.Frames[(int)CurrentFrame] is int)
                CurrentFrameInfo = Data.Frames[Data.Frames[(int)CurrentFrame]];
            else
                CurrentFrameInfo = Data.Frames[(int)CurrentFrame];

            Sprite.TextureRect = GetIntRect();
            Sprite.Origin = CurrentFrameInfo.Origin;

            return true;
        }