Skip to content

Instantly share code, notes, and snippets.

@johnlindquist
Created April 6, 2011 18:53
Show Gist options
  • Save johnlindquist/906262 to your computer and use it in GitHub Desktop.
Save johnlindquist/906262 to your computer and use it in GitHub Desktop.
elseif event.phase == "ended" and ghostObject.isReady then
-- Finger lifted from screen; fling the Roly Poly!
local flingNow = function()
-- handle the shot orb and disable screen swiping
transition.cancel( ghostTween )
shotOrb.isVisible = false
shotArrow.isVisible = false
canSwipe = false
local x = event.x
local y = event.y
local xForce = (-1 * (x - ghostObject.x)) * 2.15 --> 2.75
local yForce = (-1 * (y - ghostObject.y)) * 2.15 --> 2.75
audio.play( weeSound )
ghostObject:stopAtFrame( 2 )
ghostObject.bodyType = "dynamic"
ghostObject:applyForce( xForce, yForce, ghostObject.x, ghostObject.y )
ghostObject.isReady = false
ghostObject.inAir = true
-- START TRAILING DOTS BLOCK
local i
-- First, delete previous trail
for i = trailGroup.numChildren,1,-1 do
local child = trailGroup[i]
child.parent:remove( child )
child = nil
end
local startDotCreation = function()
local createDot = function()
local trailDot
if ghostObject.trailNum == 0 then
trailDot = display.newCircle( gameGroup, ghostObject.x, ghostObject.y, 2.5 )
else
trailDot = display.newCircle( gameGroup, ghostObject.x, ghostObject.y, 1.5 )
end
trailDot:setFillColor( 255, 255, 255, 255 )
trailDot.alpha = 1.0
trailGroup:insert( trailDot )
--gameGroup:insert( trailGroup )
if ghostObject.trailNum == 0 then
ghostObject.trailNum = 1
else
ghostObject.trailNum = 0
end
end
dotTimer = timer.performWithDelay( 50, createDot, 50 )
end
local startDotTimer = timer.performWithDelay( 50, startDotCreation, 1 )
-- END TRAILING DOTS BLOCK
-- Show the blast glow
blastGlow.x = ghostObject.x
blastGlow.y = ghostObject.y
blastGlow.isVisible = true
end
transition.to( shotOrb, { time=175, xScale=0.1, yScale=0.1, onComplete=flingNow } )
audio.play( blastOffSound )
-- Make sure pause button is hidden/inactive
pauseBtn.isVisible = false
pauseBtn.isActive = false
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment