Example #1
0
        void updateElement(GameTime gameTime, PopupTextElement element)
        {
            if (element.FadeDirection == FadeDirection.Static)
            {
                return;
            }

            if (element.FadeOutCounter.Completed)
            {
                element.DeleteMe = true;
                return;
            }

            // move element (up by default)
            element.TextElement.Position -= new Vector2(0, (float)(element.MovementSpeed * gameTime.ElapsedGameTime.TotalSeconds));
            element.FadeOutCounter.Update(gameTime.ElapsedGameTime.Milliseconds);
        }
Example #2
0
        public void AddMessage(string msg, Vector2 position, MessageType type)
        {
            PopupTextElement newPopup = null;

            switch (type)
            {
            case MessageType.FadingText_Fast:
                newPopup = new PopupTextElement(
                    new TextElement <string>(
                        msg,
                        font,
                        new TextElementSettings {
                    ForegroundColor = Color.Orange
                }
                        )
                {
                    Position = position
                })
                {
                    FadeTimeTotalMs = 500,
                    FadeDirection   = FadeDirection.Up,
                };
                break;

            case MessageType.FadingText_Slow:
                newPopup = new PopupTextElement(
                    new TextElement <string>(
                        msg,
                        font,
                        new TextElementSettings {
                    ForegroundColor = Color.Orange
                }
                        )
                {
                    Position = position
                })
                {
                    FadeTimeTotalMs = 1000,
                    FadeDirection   = FadeDirection.Up,
                };
                break;

            case MessageType.StaticText:
                newPopup = new PopupTextElement(
                    new TextElement <string>(
                        msg,
                        font,
                        new TextElementSettings {
                    ForegroundColor = Color.GreenYellow
                }
                        )
                {
                    Position = position
                });
                break;
            }

            if (newPopup != null)
            {
                newPopup.TextElement.Load(loader);
                messages.Add(newPopup);
            }
        }