The billionaire behind one of the most triumphant videogames of all time came to view Apple Inc. as an existential threat to his dream of the future. So Tim Sweeney decided to fight. He gave his dispute with the world’s largest company a code name: project liberty.

The skirmish was a bold tactic from a man who built an empire around “Fortnite,” the online multiplayer shooter game filled with cartoonish characters that ended up a phenomenon embarrassed by teenagers from around the world. The ambition of Epic Games Inc.’s chief executive was that Fortnite’s legions of devoted young fans could turn it into a thriving social network, and help realize his vision of the “metaverse,” a shared virtual world where people may one day live, work and hang out together.

Mr. Sweeney saw Apple as a central roadblock to that vision, according to people familiar with his reasoning and documents revealed in a recent court proceeding, due to the tight control of the iPhone maker over how people access “Fortnite” and any other mobile apps from Epic. Apple’s App Store takes a 30% cut of Epic’s revenue from those users. 

Epic avoided Apple’s fees and rules last August by introducing its own system for processing user purchases into mobile versions of “Fortnite”. It also made preparations for a bigger legal and public-relations campaign, complete with a video mocking an acclaimed Apple ad and the social-media hashtag #FreeFortnite.