alestane

Module sample

Dec 4th, 2012
256
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.90 KB | None | 0 0
  1. return function( Puzzle ) -- Storyboard View
  2.  
  3.     local Background = display.newGroup()
  4.     Puzzle:insert(Background)
  5.     Background.isVisible = false
  6.    
  7.     Puzzle:addEventListener('onPuzzleLoad', Background)
  8.     function Background:onPuzzleLoad(event)
  9.         local puzzleId = event.puzzleId
  10.         local final = display.newImageRect("Puzzles/" ..puzzleId .. "/final.png", _W, _H)
  11.         self:insert(final); self.final = final
  12.         final.x, final.y = _W*.5, _H*.5
  13.         final.isVisible = false
  14.     end
  15.    
  16.     Puzzle:addEventListener('onPuzzleShow', Background)
  17.     function Background:onPuzzleShow(event)
  18.         if (event.phase == 'began') then
  19.             display.setDefault( "background", 255,255,255 )
  20.             self.isVisible = true
  21.         end
  22.     end
  23.    
  24.     Puzzle:addEventListener('onPuzzleComplete', Background)
  25.     function Background:onPuzzleComplete(event)
  26.         display.setDefault( "background", 153, 204, 255)
  27.         self.final.isVisible = true
  28.     end
  29.      
  30.     return Background
  31. end
Advertisement
Add Comment
Please, Sign In to add comment