Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs

ct.js

Create cool 2D games with a free game editor! · By Cosmo Myzrail Gorynych

setTimeout() not known

A topic by JB007 created 48 days ago Views: 62 Replies: 3
Viewing posts 1 to 4

While following the Spacer shooter tutorial the IDE does not seem to know the  setTimeout() function. This function has a squiggly underlline and hovering over reveals:

Cannot find name ' setTimeout'

SNIPPET OF CODE:

 if (ct.room.lives <= 0) {
        this.kill = true;
        setTimeout(function() {
            ct.rooms.switch('Main');
        }, 1000);
    }

Although the game complies and plays without issue. I downloaded the current version 2 days ago as a Linux 64 bit release.

Developer

Ct.js bundles a portion of default DOM typings so the suggestions are not so polluted, and thus some names are missing, but it is more a warning than an error. You can suppress the warning by writing this.setTimeout instead of setTimeout.

Thank you Cosmo for the explanation.

Developer(+1)

Shoot, I meant window.setTimeout instead of this.setTimeout.