Nobuhiko Obayashi, who died on April 10 at age 82, finished directing two films after receiving a diagnosis of terminal lung cancer in 2016. “Hanagatami,” an ensemble drama set in Kyushu as Japan marched to war in the early 1940s, was released in 2017. “Labyrinth of Cinema,” which premiered at the 2019 Tokyo International Film Festival with a frail but still feisty Obayashi in attendance, has since played at festivals abroad and received well-deserved raves from critics.

Instead of a feeble final effort by a dying man, “Labyrinth of Cinema” is bursting with energy, passion and dreamlike invention, and while conveying a strong antiwar message, it is anything but preachy. The tone is that of a cheeky black comedy — minus the cynicism — while the border between reality and fantasy dissolves into a colorful alternative universe that is uniquely Obayashi’s.

As an in-demand maker of TV commercials starting from the 1960s, Obayashi became a master at holding the audience’s attention moment to moment, though in “Labyrinth of Cinema” he does it not with Hollywood celebrities like Charles Bronson, star of Obayashi’s well-remembered men’s toiletries ad, but rather with his unfettered visual imagination and abundant storytelling gifts. You can’t help but pay attention when an avuncular “guide” named Fanta G (YMO drummer and vocalist Yukihiro Takahashi) discourses on Japanese history as giant goldfish swim around him in a time machine.