Help! Have i misunderstood the essence of the game loop?

Sup Guys,
hope this message reaches you in good health.

Some background: Junior dev, but complete novice game dev currently working on (kinda just started) a basic playing card game (for Android and iOS) as a personal project :slight_smile:

The Problem: I’ve written some very basic image scaling logic that just enlarges a button while that button is being held and pressed (touched), there are 2 buttons in question but the scaling effect only seems to be applying to the first button pressed with nothing happening to the second. Any thoughts as to why would be greatly appreciated:

Game1 : Game Class

    protected override void LoadContent()
    {
        GameContent.LoadAll(Content);

        // Add main menu screen
        GameStateManager.AddScreen(new MainMenuState(GraphicsDevice));

        // Create a new SpriteBatch, which can be used to draw textures.
        spriteBatch = new SpriteBatch(GraphicsDevice);
    }

    protected override void Draw(GameTime gameTime)
    {
        spriteBatch.Begin();

        GameStateManager.Draw(spriteBatch);

        spriteBatch.End();
        base.Draw(gameTime);
    }

    protected override void Update(GameTime gameTime)
    {
        GameStateManager.Update(gameTime);

        base.Update(gameTime);
    }

GameStateManager Class

    public static void Update(GameTime gameTime)
    {
          if (_screens.Count > 0)
            {
                _screens.Peek().Update(gameTime);

                foreach (var button in _screens.Peek().GetComponents())
                {
                    button.Update();
                }
            }
    }

Note: The Draw method is also called the same way

Relevant bits in the Main Menu class

    private List<Component> Buttons { get; set; }

    public MainMenuState(GraphicsDevice graphicsDevice)
        : base(graphicsDevice)
    {
        Name = GameScreen.MainMenu;

        Buttons = new List<Component>()
        {
            new Button("Join", GameContent.JoinGameButtonImage, DeviceScreenSize, -100),
            new Button("Create", GameContent.CreateGameButtonImage, DeviceScreenSize, 250)
        };
    }

    public override List<Component> GetComponents() 
    {
        return Buttons;
    }

Button Class

    public override void Draw(SpriteBatch spriteBatch)
    {
        spriteBatch.Draw(_texture, new Vector2(_deviceScreenSize.Width / 2, _deviceScreenSize.Height / 2 + _yAxisPosition), null, Color.White, 0, new Vector2(ButtonOrigin, 0), Scale, SpriteEffects.None, 0);
    }

    public override void Update()
    {
        while (TouchPanel.IsGestureAvailable)
        {
            var touch = TouchPanel.ReadGesture();
            if (Surface.Contains(touch.Position) && touch.GestureType == GestureType.Hold)
            {
                IsPressed = true;
                Console.WriteLine(Name + " button is held");
            }
        }

        if (TouchCollection.Count == 0)
        {
            IsPressed = false;
        }
    }

Is there any reason to use gestures instead of the more simple TouchCollection? Never worked with them, so maybe, they just don’t report as you expect them to.

I would actually suggest to use the debugger in teh buttons update method and find out, why (or which of) the condition is not met for the other button

Thanks for the feedback @reiti.net, I initially did use TouchCollection but at the time i couldnt figure out a clean way to achieve my desired effect. Ive since revisited it and figured it out (using TouchCollection), however I’ll still need to use the gestures going forward right ? Especially once i start adding in dragging and dropping. Or can that also be done via TouchCollection?