Why do learning games fail or succeed? Recent evidence suggests that attention forms an important moderator of learning from games. While existing media effects and learning theories acknowledge the role of attentional limits, they fail to account for the specific ways that games as interactive media steer attention. In response, we here develop the Task-Attention Theory of Game Learning. Drawing on current psychological and games research, task-attention theory argues that games as interactive media demand and structure the pursuit of tasks, which ties into distinct attentional mechanisms, namely learned attentional sets which focus attentional selection onto task-relevant features, as well as active sampling: users navigate and manipulate the game to elicit task-relevant information. This active sampling and selection precedes and moderates what information can be learned. We identify task-related game features (mechanics, goals, rewards and uncertainty) and demands (cognitive and perceptual load, pressure) that affect active sampling and attentional selection. We articulate implications and future work for game-based learning research and design, as well as wider media effects, learning, and HCI research.