Tutorial 1 - addGroup and addSprite
  • The following id selectors, background, actors, playerMissleLayer, enemiesMissleLayer - are they always dynamically loaded into the DOM once the game starts? I think that helps my understanding because I was under the impression that we had to also create these id's in the html page.




    $("#playground").playground({height: PLAYGROUND_HEIGHT, width: PLAYGROUND_WIDTH})
    .addGroup("background", {width: PLAYGROUND_WIDTH, height: PLAYGROUND_HEIGHT}).end()
    .addGroup("actors", {width: PLAYGROUND_WIDTH, height: PLAYGROUND_HEIGHT}).end()
    .addGroup("playerMissileLayer",{width: PLAYGROUND_WIDTH, height: PLAYGROUND_HEIGHT}).end()
    .addGroup("enemiesMissileLayer",{width: PLAYGROUND_WIDTH, height: PLAYGROUND_HEIGHT});


    Thanks

  • selimselim
    Accepted Answer
    They are created automatically but not when the gameStart function is called. In fact they are added to the DOM immediately but are not visible because they are added to the scenegraph DOM element (the son of the playground div you choosed) and it is invisible as long as the game hasn't been started.

    What the startGame function does is to load the images that correspond to those sprites and onces it's done make the scenegraph visible.
  • I get it.  Thanks!

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!