Skip to content

Instantly share code, notes, and snippets.

@parse
Created March 14, 2013 13:17
Show Gist options
  • Save parse/5161222 to your computer and use it in GitHub Desktop.
Save parse/5161222 to your computer and use it in GitHub Desktop.
-- Code created by Kwik - Copyright: kwiksher.com
-- Version: 2.2.5
module(..., package.seeall)
function new()
local numPages = 3
local menuGroup = display.newGroup()
local dispose
local _W = 1536
local _H = 2048
-- Audio callings
local blinq_intromelo = audio.loadStream( audioDir.."blinq_intromelody.mp3")
local drawScreen = function()
local curPage = 1
if (kBookmark == 1) then
local path = system.pathForFile( "book.txt", system.DocumentsDirectory )
local file = io.open( path, "w+" )
file:write ( curPage.."\n1" )
io.close( file )
end
math.randomseed(os.time())
if (kAutoPlay > 0) then
local function act_autoPlay (event)
if(curPage < numPages) then
if(kBidi == false) then
dispose(); director:changeScene( "page_"..curPage+1, "moveFromRight" )
else
dispose(); director:changeScene( "page_"..curPage-1, "moveFromLeft" )
end
end
end
timerStash.timer_AP = timer.performWithDelay( kAutoPlay*1000, act_autoPlay, 1 )
end
-- Layer names
local bg
local blinqintro
-- (TOP) External code will render here
-- bg positioning
bg = display.newRect( -1, -4, 1538, 2053 )
bg:setFillColor (237, 233, 233)
bg.alpha = 1; bg.oldAlpha = 1
menuGroup:insert(1,bg); menuGroup.bg = bg
-- blinqintro positioning
blinqintro = movieclip.newAnim{ imgDir.."blinqanim_1.png", imgDir.."blinqanim_2.png", imgDir.."blinqanim_3.png", imgDir.."blinqanim_4.png", imgDir.."blinqanim_5.png", imgDir.."blinqanim_6.png", imgDir.."blinqanim_7.png", imgDir.."blinqanim_8.png", imgDir.."blinqanim_9.png", imgDir.."blinqanim_10.png", imgDir.."blinqanim_11.png", imgDir.."blinqanim_12.png", imgDir.."blinqanim_13.png", imgDir.."blinqanim_14.png", imgDir.."blinqanim_15.png", imgDir.."blinqanim_16.png", imgDir.."blinqanim_17.png", imgDir.."blinqanim_18.png", imgDir.."blinqanim_19.png", imgDir.."blinqanim_20.png"} ;
blinqintro.x = 768; blinqintro.y = 1022; blinqintro.alpha = 1; blinqintro.oldAlpha = 1
blinqintro:play{loop=1};
blinqintro.name = "blinqintro"
menuGroup:insert(blinqintro); menuGroup.blinqintro = blinqintro
-- Group(s) creation
-- (MIDDLE) External code will render here
-- swipe this page with spacer of 120 in normal direction
Gesture.activate( bg, {swipeLength=120} )
local function pageSwap (event )
if event.phase == "ended" and event.direction ~= nil then
local wPage = curPage
local direction
if event.direction == "left" and kBidi == false then
wPage = curPage + 1
if wPage > numPages then wPage = curPage end
direction = "moveFromRight"
elseif event.direction == "left" and kBidi == true then
wPage = curPage - 1
if wPage < 1 then wPage = 1 end
direction = "moveFromLeft"
elseif event.direction == "right" and kBidi == true then
wPage = curPage + 1
if wPage > numPages then wPage = curPage end
direction = "moveFromRight"
elseif event.direction == "right" and kBidi == false then
wPage = curPage - 1
if wPage < 1 then wPage = 1 end
direction = "moveFromLeft"
end
if wPage ~= curPage then dispose();
dispose(); director:changeScene("page_"..wPage, direction)
end
end
end
bg:addEventListener( Gesture.SWIPE_EVENT, pageSwap )
dispose = function (event)
cancelAllTimers();
cancelAllTransitions()
audio.stop(1);
audio.dispose(blinq_intromelo);
blinq_intromelo = nil
bg:removeEventListener ( Gesture.SWIPE_EVENT, pageSwap ); Gesture.deactivate(bg)
end
-- (BOTTOM) External code will render here
end
drawScreen()
local myClosure_blinq_intromelo = function()
audio.setVolume(1, { channel=1} );
audio.play(blinq_intromelo, { channel=1, loops=0, fadein=500 } )
end
timerStash.newTimer_230 = timer.performWithDelay(0, myClosure_blinq_intromelo, 1)
return menuGroup
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment