tilesetName = 'flower'; $this->animations = [ 'low' => ['flags' => [], 'coords' => self::frames([self::LOW])], 'high' => ['flags' => [], 'coords' => self::frames([self::HIGH])], ]; $this->setAnimation('low'); } public function update(float $deltaTime): void { $this->clock += $deltaTime; while ($this->clock >= self::FRAME) { $this->clock -= self::FRAME; // the counter only runs on even frames if ((++$this->frames & 1) === 0 && --$this->counter === 0) { $this->counter = self::STATES[$this->phase][1]; $this->phase = ($this->phase + 1) & 3; $this->setAnimation(self::STATES[$this->phase][0] ? 'high' : 'low'); } } } }