Created
January 15, 2012 03:25
-
-
Save kengonakajima/1614147 to your computer and use it in GitHub Desktop.
Moai: delaying setTexture
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
---------------------------------------------------------------- | |
-- 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 ) | |
prop:moveRot ( 360, 1.5 ) | |
t = MOAITexture.new() | |
--t:load("cathead.png") | |
local d = MOAITileDeck2D.new() | |
d:setTexture(t) | |
d:setSize(1,1,1,1,0,0,1,1) | |
d:setRect(-0.5,-0.5,0.5,0.5) | |
prop2 = MOAIProp2D.new() | |
prop2:setDeck(d) | |
prop2:setScl(30,30) | |
layer:insertProp(prop2) | |
th = MOAIThread.new() | |
th:run( | |
function() | |
local cnt=1 | |
while true do | |
coroutine.yield() | |
cnt = cnt + 1 | |
if ( cnt % 100 ) == 0 then | |
print("r") | |
if cnt == 200 then | |
gfxQuad:setTexture( "cathead.png") | |
end | |
if cnt== 100 then | |
t:load("cathead.png") | |
end | |
end | |
end | |
end) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment