alestane icon

Module sample

alestane | PRO | 12/04/12 02:52:03 PM UTC | 0 ⭐ | 306 👁️ | Never ⏰ | []
Lua |

900 B

|

None

|

0 👍

/

0 👎

return function( Puzzle ) -- Storyboard View
 
    local Background = display.newGroup()
    Puzzle:insert(Background)
    Background.isVisible = false
    
    Puzzle:addEventListener('onPuzzleLoad', Background)
    function Background:onPuzzleLoad(event)
        local puzzleId = event.puzzleId
        local final = display.newImageRect("Puzzles/" ..puzzleId .. "/final.png", _W, _H)
        self:insert(final); self.final = final
        final.x, final.y = _W*.5, _H*.5
        final.isVisible = false
    end
    
    Puzzle:addEventListener('onPuzzleShow', Background)
    function Background:onPuzzleShow(event)
        if (event.phase == 'began') then
            display.setDefault( "background", 255,255,255 )
            self.isVisible = true
        end
    end
    
    Puzzle:addEventListener('onPuzzleComplete', Background)
    function Background:onPuzzleComplete(event)
        display.setDefault( "background", 153, 204, 255)
        self.final.isVisible = true
    end
      
    return Background
end

Comments