title: Z-Index Vertical Carousel Typescript
body: <p>I have a problem with sorting the z-index priority on phaser. I've created already a rotating vertical carousel but I need to put the <code>center image</code> as seen on the photo below as the highest priority z-index. The <code>swap(a,b)</code> is the one that swaps z-index. This code is inside an update function that updates every frame (so the center image changes all the time but it needs to be always on top of all other image).</p>
  
  <pre><code>var r = 0,
      n = this.itemCount,
      a = this.symW / 2,
      b = this.symH / 2;
  for (var i = 0; i &lt; n; i++) {
      t = 2 * Math.PI / n;
      angle = i * t + this.currentAngle;
      r = b / Math.tan(t / 2);
      pX = cX;
      pX = Math.round(Math.cos(angle) * -r * 0.5);
      pY = Math.round(Math.sin(angle) * r + cY);
      //this.swap(this.symbols[i + 1], this.symbols[i]);
      this.symbols[i].x = pX + 250;
      this.symbols[i].y = pY - 150;
  }
  if (Math.abs(this.currentAngle) &gt;= 2 * Math.PI)
      this.currentAngle = 0;
  else this.currentAngle -= 0.01;
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/P7s66.jpg" alt="enter image description here"></p>