Skip to content

Instantly share code, notes, and snippets.

@kengonakajima
Created January 15, 2012 21:31
Show Gist options
  • Save kengonakajima/1617431 to your computer and use it in GitHub Desktop.
Save kengonakajima/1617431 to your computer and use it in GitHub Desktop.
Moai allows delayed audio file loading
----------------------------------------------------------------
-- Copyright (c) 2010-2011 Zipline Games, Inc.
-- All Rights Reserved.
-- http://getmoai.com
----------------------------------------------------------------
MOAISim.openWindow ( "test", 320, 480 )
viewport = MOAIViewport.new ()
viewport:setSize ( 320, 480 )
viewport:setScale ( 320, -480 )
layer = MOAILayer2D.new ()
layer:setViewport ( viewport )
MOAISim.pushRenderPass ( layer )
gfxQuad = MOAIGfxQuad2D.new ()
gfxQuad:setTexture ( "cathead.png" )
gfxQuad:setRect ( -64, -64, 64, 64 )
gfxQuad:setUVRect ( 0, 0, 1, 1 )
prop = MOAIProp2D.new ()
prop:setDeck ( gfxQuad )
layer:insertProp ( prop )
MOAIUntzSystem.initialize ()
sound = MOAIUntzSound.new ()
--sound:load ( 'mono16.wav' )
sound:setVolume ( 1 )
sound:setLooping ( false )
sound:play ()
t = MOAIThread.new()
t:run( function()
cnt=0
while true do
cnt = cnt + 1
if ( cnt% 100)==0 then
if cnt == 200 then
sound:load ( 'mono16.wav' )
end
sound:play()
print("play:",cnt)
prop:moveRot ( 360, 1.5 )
end
coroutine.yield()
end
end)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment