Skip to content

Instantly share code, notes, and snippets.

@defHLT
Created November 16, 2013 22:31
Show Gist options
  • Save defHLT/7506233 to your computer and use it in GitHub Desktop.
Save defHLT/7506233 to your computer and use it in GitHub Desktop.
io.stdout:setvbuf 'no'
print ( [[ **************************************************************** ]] )
MOAISim.openWindow ( "float", 1024, 800 )
viewport = MOAIViewport.new ()
viewport:setSize ( 1024, 800)
viewport:setScale ( 1024, 800)
layer = MOAILayer.new ()
layer:setViewport ( viewport )
MOAISim.pushRenderPass ( layer )
camera = MOAICamera.new ()
camera:setLoc ( 0, 0, camera:getFocalLength ( 4 ))
layer:setCamera ( camera )
function onDraw()
MOAIGfxDevice.setPenColor ( 1, 1, 1, 1 )
MOAIDraw.fillCircle ( 0, 0, 0.10, 64 )
end
scriptDeck = MOAIScriptDeck.new ()
scriptDeck:setRect ( -0.1, -0.1, 0.1, 0.1 )
scriptDeck:setDrawCallback ( onDraw )
prop1 = MOAIProp.new ()
prop1:setDeck(scriptDeck)
prop1:setLoc ( -0.5, 0, 0 )
prop2 = MOAIProp.new ()
prop2:setDeck(scriptDeck)
prop2:setLoc ( 0.0, 0, 0 )
prop3 = MOAIProp.new ()
prop3:setDeck(scriptDeck)
prop3:setLoc ( 0.5, 0, 0 )
layer:insertProp ( prop1 )
layer:insertProp ( prop2 )
layer:insertProp ( prop3 )
animRoot = MOAIAnim.new ()
animRoot:setMode(MOAITimer.CONTINUE)
animRoot:start()
anim1a = prop1:moveRot ( 360e3, 360e3, 360e3, 3e2, MOAIEaseType.LINEAR )
anim1b = prop1:moveLoc( 0, 0.5, 0.5, MOAIEaseType.LINEAR )
anim1b:setMode(MOAITimer.PING_PONG)
anim2 = prop2:moveRot( 360e3, 360e3, 360e3, 3e2, MOAIEaseType.LINEAR )
anim3a = prop3:moveRot( 360e3, 360e3, 360e3, 3e2, MOAIEaseType.LINEAR )
anim3b = prop3:moveLoc( 0, 0.5, 0.5, MOAIEaseType.LINEAR )
anim3b:setMode(MOAITimer.PING_PONG)
animRoot:addChild ( anim1a )
animRoot:addChild ( anim1b )
animRoot:addChild ( anim1b )
animRoot:addChild ( anim3a )
animRoot:addChild ( anim3b )
--MOAIInputMgr.device.pointer:setCallback(function(x,y)
--end)
MOAIInputMgr.device.mouseRight:setCallback(function(dn)
if dn then
mouseRDN = true
else
mouseRDN = false
end
end)
function toggleAnim (anim)
if anim:isBusy () then
anim:stop()
else
anim:start()
end
end
if MOAIInputMgr.device.keyboard then
print("Keyboard")
MOAIInputMgr.device.keyboard:setCallback(
function(key,down)
if down==true then
char = string.char(tostring(key))
if char == 's' then
toggleAnim ( animRoot )
elseif char == 't' then
toggleAnim ( anim2 )
end
end
end)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment