Skip to content

Instantly share code, notes, and snippets.

@iamricard
Created January 17, 2014 12:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iamricard/8472367 to your computer and use it in GitHub Desktop.
Save iamricard/8472367 to your computer and use it in GitHub Desktop.
facebook
MOAISim.openWindow ( "Test Menu", 960, 640 )
MOAIGfxDevice.getFrameBuffer():setClearColor ( 1, 1, 1, 1 )
-- VIEWPORT
viewport = MOAIViewport.new ()
viewport:setSize ( 960, 640 )
viewport:setScale ( 960, 640 )
-- LAYER
partition = MOAIPartition.new ()
layer = MOAILayer2D.new ()
layer:setViewport ( viewport )
layer:setPartition ( partition )
-- QUAD + PROP
gfxQuad = MOAIGfxQuad2D.new ()
prop = MOAIProp.new ()
gfxQuad:setTexture ( 'facebook-square.png' )
gfxQuad:setRect ( 0, 0, 280, 280 )
prop:setDeck ( gfxQuad )
prop:setColor ( 0, 0, 1, 1 )
prop.name = "facebook"
layer:insertProp ( prop )
-- RENDER
MOAISim.pushRenderPass ( layer )
-- INPUT LISTENERS
function onTouchEvent ( eventType, idx, x, y, tapCount )
if ( eventType == MOAITouchSensor.TOUCH_DOWN ) then
touchX, touchY = layer:wndToWorld ( x, y )
local propAtPoint = partition:propForPoint ( touchX, touchY )
if propAtPoint.name and propAtPoint.name == 'facebook' then
if propAtPoint.name == 'facebook' then
MOAIDialog.showDialog ( propAtPoint.name, touchY, "Yes", "Maybe", "No", true, nil )
end
else
return false
end
else
return false
end
end
MOAIInputMgr.device.touch:setCallback ( onTouchEvent )
-- Window -> Viewport -> 1+ layer -> (1+ quad -> 1+ prop)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment