Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --introClass.lua--------------
- local lfs = require "lfs"
- local _M = {}
- local centerX = display.contentCenterX
- local centerY = display.contentCenterY
- --Forward declaration of variables
- local splashFunction = {}
- local splashCounter = 1
- local pathForImages = "ImageShow/"
- local filenames = {}
- local splashImage
- local baseDir
- local baseDirDevice
- local environment = system.getInfo( "environment" )
- _M.group = display.newGroup()
- _G.doneSplash = false
- --FUNCTIONS--
- -- path is relative to the baseDirectory
- function _M.getFiles()
- if environment == "simulator" then
- baseDir = system.pathForFile('main.lua'):gsub("main.lua", "")
- for file in lfs.dir(baseDir .. pathForImages) do
- if (file ~= '.' and file ~= '..' and file ~= ".DS_Store" ) then
- table.insert(filenames, file)
- end
- end
- else
- baseDir = system.ResourceDirectory
- for file in lfs.dir(baseDir .. "/" .. pathForImages) do
- if (file ~= '.' and file ~= '..' and file ~= ".DS_Store" ) then
- table.insert(filenames, file)
- end
- end
- if (#filenames == 0) then return false end
- end
- return filenames
- end
- function _M.printSplashImageFolderContent()
- for k,v in ipairs(filenames) do
- print(k,v)
- end
- end
- function _M.playGame()
- print("End of introFunction")
- system.vibrate( )
- system.openURL( "http://www.3claws.org" )
- end
- function _M.splashFunction(self, event)
- if event.phase == "began" then
- if _G.doneSplash == false then
- if splashCounter < #filenames then
- splashImage = display.newImageRect( pathForImages .. filenames[splashCounter], 480, 320 )
- splashImage.x, splashImage.y = display.contentCenterX, display.contentCenterY
- splashImage.alpha = 1
- _M.group:insert(splashImage)
- transition.to( splashImage, {time=500, alpha=0, onComplete= function()
- display.remove( splashImage )
- splashImage = display.newImageRect( pathForImages .. filenames[splashCounter], 480, 320 )
- splashImage.x, splashImage.y = display.contentCenterX, display.contentCenterY
- splashImage.alpha = 0
- _M.group:insert(splashImage)
- transition.to( splashImage, {time=500, alpha=1})
- return true end} )
- elseif splashCounter == #filenames then
- _G.doneSplash = true
- _M.playGame()
- end
- splashCounter = splashCounter + 1
- return true
- end
- end
- end
- function _M.removeMusic()
- audio.stop()
- audio.dispose(introTrackSnd)
- introTrackSnd = nil
- introChan = nil
- return true
- end
- function _M:new()
- splashImage = display.newImageRect( pathForImages .. filenames[splashCounter], 480, 320 )
- splashImage.x, splashImage.y = display.contentCenterX, display.contentCenterY
- splashImage.alpha = 1
- _M.group:insert(splashImage)
- splashImage.touch = _M.splashFunction
- splashImage:addEventListener("touch", splashImage)
- return splashImage
- end
- _M.getFiles()
- _M:new()
- _M.printSplashImageFolderContent()
- print( baseDir)
- return _M
- --in main----------------
- display.setStatusBar( display.HiddenStatusBar )
- require( "introClass" )
Advertisement
Add Comment
Please, Sign In to add comment