HTML and CSS Reference
In-Depth Information
Your method in
gd.core.animate()
that fires
requestAnimationFrame()
stops running when a user leaves a tab open in the background, unlike JavaScript's tra-
ditional timers
setInterval()
and
setTimeout()
, which keep on running. This
means coupling animation with traditional timers is generally not a good idea, because tra-
ditional timers keep on running in the background. There used to be polyfills that relied
on a frame counter in the
draw()
loop, but some implementations of
requestAnim-
ationFrame()
still update a frame after a couple seconds when a user navigates away
from a tab. The most bulletproof way to use traditional and nontraditional timers is to build
a custom timer script that checks elapsed time and fires in your
draw
loop. But this sub-
ject is complicated, and we don't have the time to cover it here. Instead, we've given the
polygonGen
object a limit to how many enemies it can spawn for a quick patch.
Step 1: Create a 3D cube particle
Create a new
gd.template.Cube
entity below
PolygonGen
with this listing.