MY CODE >> Attack of the Cuteness
-- Tutorial completed by Tommy Martin
-- 8/27/2014

-- Project: Attack of the Cuteness Game
-- http://MasteringCoronaSDK.com
-- Version: 1.0
-- Copyright 2013 J. A. Whye. All Rights Reserved.
-- "Space Cute" art by Daniel Cook (Lostgarden.com) 

-- housekeeping stuff

display.setStatusBar(display.HiddenStatusBar)

local centerX = display.contentCenterX
local centerY = display.contentCenterY

-- set up forward references

local spawnEnemy
local shipSmash
local startGame
local gameTitle
local scoreText
local score = 0
local hitPlanet
local planet

-- preload audio

local sndKill = audio.loadSound("boing-1.wav")
local sndBlast = audio.loadSound("blast.mp3")
local sndLose = audio.loadSound("wahwahwah.mp3")

-- create play screen

local function createPlayScreen ()
	
  local background = display.newImage("background.png")
  background.x = centerX
  background.scale = .2
  background.y = 130
  background.alpha = 0
  --background:addEventListener ( "tap", shipSmash )
	
  transition.to( background, { time = 2000, y = centerY } )
	
  planet = display.newImage("planet.png")
  planet.x = centerX
  planet.y = display.contentHeight + 60
  planet.alpha = 0
  planet.xScale = 2
  planet.yScale = 2
  --planet:addEventListener ( "tap", shipSmash )
	
  transition.to( planet, { time = 2000, y = centerY } )
	
  transition.to( background, { time = 2000, y = centerY, alpha = 1 } )
	
  local function showTitle()
    gameTitle = display.newImage("gametitle.png")
    gameTitle.alpha = 0
    gameTitle:scale(4, 4)
    transition.to ( gameTitle, { time = 500, alpha = 1, xScale = 1, yScale = 1 } )
    startGame()
  end
	
  transition.to( planet, { time = 2000, y = centerY, alpha = 1, xScale = 1, yScale = 1, onComplete = showTitle } )
	
end
-- game functions

function spawnEnemy ()
	
  local enemy = display.newImage("beetleship.png")
  enemy:addEventListener ( "tap", shipSmash )
	
  if math.random(2) == 1 then
    enemy.x = math.random ( -100, -10 )
    else
      enemy.x = math.random (display.contentWidth + 10, display.contentWidth + 100 )
    end
  enemy.y = math.random (display.contentHeight)
  enemy.trans = transition.to (enemy, { x = centerX, y = centerY, time = 3500, onComplete = hitPlanet } )
	
end

function startGame () -- 2000 is two seconds
	
  local text = display.newText( "Tap here to start. Protect the planet!", 0, 0, "Helvetica", 24)
  text.x = centerX
  text.y =  display.contentHeight - 30
  text:setTextColor(255, 255, 255) 
  text.alpha = .75
	
  local function goAway(event)
    display.remove(event.target)
    text = nil
    display.remove(gameTitle)
    spawnEnemy()
    scoreText = display.newText( "Score: 0", 0, 0, "Helvetica", 22 )
    scoreText.x = centerX; scoreText.y = display.screenOriginY + 10
    score = 0
  end
	
  text:addEventListener ( "tap", goAway )
	
end

local function planetDamage ()
  local function goAway(obj)
    planet.xScale = 1
    planet.yScale = 1
    --planet.alpha = planet.numHits / 10
  end
  transition.to ( planet, { time = 200, xScale = 1.2, yScale = 1.2, alpha =1, onComplete = goAway} )
end

function hitPlanet (obj)
  display.remove( obj )
  planetDamage()
  audio.play(sndBlast)
  spawnEnemy()
end

function shipSmash (event)
  local obj = event.target
  display.remove( obj )
  audio.play(sndKill)
  transition.cancel ( event.target.trans )
  score = score + 28
  scoreText.text = "Score: " .. score
  spawnEnemy()
  return true
end

createPlayScreen()