Reader small image

You're reading from  Corona SDK Mobile Game Development: Beginner's Guide

Product typeBook
Published inMar 2015
Publisher
ISBN-139781783559343
Edition1st Edition
Tools
Right arrow
Author (1)
Michelle M Fernandez
Michelle M Fernandez
Right arrow

Time for action – launching the panda


Let's add a touch event for the panda so that it flings toward the stars. The powerShot object will play a role in helping the player visualize how much power needs to be applied to the panda, before it launches into the air.

  1. Implement touch events for the panda. Create a local function called onScreenTouch() with an event parameter:

    local onScreenTouch = function( event )
  2. With gameIsActive initiated, add in an if statement for when the touch event starts, by using event.phase == "began". During this event, use the "crouch" animation set to prepare panda for launch:

      if gameIsActive then
        if event.phase == "began" and panda.inAir == false then
    
          panda.y = 225
          panda.isReady = true
          powerShot.isVisible = true
          powerShot.alpha = 0.75
          powerShot.x = panda.x; powerShot.y = panda.y
          powerShot.xScale = 0.1; powerShot.yScale = 0.1
    
          arrow.isVisible = true
    
          panda:setSequence("crouch")
          panda:play()
  3. Add an elseif statement...

lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
Corona SDK Mobile Game Development: Beginner's Guide
Published in: Mar 2015Publisher: ISBN-13: 9781783559343

Author (1)