Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

5. Animating our Game > Time for action – starting the game

Time for action – starting the game

Right now we need to set the off screen position for the panda and have it transition to its starting launch location so the user can interact with it.

  1. After adding the variables, create a new local function called startNewRound() and add an if statement to initiate the panda object into the scene.
    local startNewRound = function()
      if panda then
  2. Add a new local function called activateRound() within startNewRound(). Set the starting position of the panda display object on screen and add ground:toFront() so that ground appears in front of the panda character.
        local activateRound = function()
          
          waitingForNewRound = false
              
          if restartTimer then
            timer.cancel( restartTimer )
          end
          
          ground:toFront()
          panda.x = 240;
          panda.y = 300;
          panda.rotation = 0
          panda.isVisible = true
          panda.isBodyActive = true

  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free 10-Day Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint