Permalink
Browse files

added example of visbility inheritance (thank you, Tommo!)

  • Loading branch information...
1 parent cf311d5 commit 1321ffa470b28e0625d554c14493413639185377 @patrickmeehan patrickmeehan committed Mar 12, 2013
@@ -0,0 +1,84 @@
+----------------------------------------------------------------
+-- Copyright (c) 2010-2011 Zipline Games, Inc.
+-- All Rights Reserved.
+-- http://getmoai.com
+----------------------------------------------------------------
+
+function printf ( ... )
+ return io.stdout:write ( string.format ( ... ))
+end
+
+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 ( "moai.png" )
+gfxQuad:setRect ( -128, -128, 128, 128 )
+gfxQuad:setUVRect ( 0, 0, 1, 1 )
+
+parent = MOAIProp2D.new ()
+parent:setDeck ( gfxQuad )
+parent:setLoc(-10,10)
+layer:insertProp ( parent )
+
+child = MOAIProp2D.new ()
+child:setDeck ( gfxQuad )
+child:setLoc(10,-10)
+layer:insertProp ( child )
+
+child:setAttrLink ( MOAIProp.INHERIT_VISIBLE, parent, MOAIProp.ATTR_VISIBLE )
+printf ( 'child.INHERIT_VISIBLE <- parent.ACTUAL_VISIBLE\n\n' )
+
+parent:setVisible ( false )
+child:setVisible ( true )
+parent:forceUpdate ()
+child:forceUpdate ()
+
+printf ( 'parent:setVisible ( false )\n' )
+printf ( 'child:setVisible ( true )\n' )
+printf ( 'parent ATTR_LOCAL_VISIBLE: %d\n', parent:getAttr ( MOAIProp.ATTR_LOCAL_VISIBLE ))
+printf ( 'child ATTR_LOCAL_VISIBLE: %d\n', child:getAttr ( MOAIProp.ATTR_LOCAL_VISIBLE ))
+printf ( 'child ATTR_VISIBLE: %d\n', child:getAttr ( MOAIProp.ATTR_VISIBLE ))
+printf ( '\n' )
+
+parent:setVisible ( false )
+child:setVisible ( false )
+parent:forceUpdate ()
+child:forceUpdate ()
+
+printf ( 'parent:setVisible ( false )\n' )
+printf ( 'child:setVisible ( false )\n' )
+printf ( 'parent ATTR_LOCAL_VISIBLE: %d\n', parent:getAttr ( MOAIProp.ATTR_LOCAL_VISIBLE ))
+printf ( 'child ATTR_LOCAL_VISIBLE: %d\n', child:getAttr ( MOAIProp.ATTR_LOCAL_VISIBLE ))
+printf ( 'child ATTR_VISIBLE: %d\n', child:getAttr ( MOAIProp.ATTR_VISIBLE ))
+printf ( '\n' )
+
+parent:setVisible ( true )
+child:setVisible ( true )
+parent:forceUpdate ()
+child:forceUpdate ()
+printf ( 'parent:setVisible ( true )\n' )
+printf ( 'child:setVisible ( true )\n' )
+printf ( 'parent ATTR_LOCAL_VISIBLE: %d\n', parent:getAttr ( MOAIProp.ATTR_LOCAL_VISIBLE ))
+printf ( 'child ATTR_LOCAL_VISIBLE: %d\n', child:getAttr ( MOAIProp.ATTR_LOCAL_VISIBLE ))
+printf ( 'child ATTR_VISIBLE: %d\n', child:getAttr ( MOAIProp.ATTR_VISIBLE ))
+printf ( '\n' )
+
+parent:setVisible ( true )
+child:setVisible ( false )
+parent:forceUpdate ()
+child:forceUpdate ()
+
+printf ( 'parent:setVisible ( true )\n' )
+printf ( 'child:setVisible ( false )\n' )
+printf ( 'parent ATTR_LOCAL_VISIBLE: %d\n', parent:getAttr ( MOAIProp.ATTR_LOCAL_VISIBLE ))
+printf ( 'child ATTR_LOCAL_VISIBLE: %d\n', child:getAttr ( MOAIProp.ATTR_LOCAL_VISIBLE ))
+printf ( 'child ATTR_VISIBLE: %d\n', child:getAttr ( MOAIProp.ATTR_VISIBLE ))
+printf ( '\n' )
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -0,0 +1,33 @@
+::----------------------------------------------------------------::
+:: Copyright (c) 2010-2011 Zipline Games, Inc.
+:: All Rights Reserved.
+:: http://getmoai.com
+::----------------------------------------------------------------::
+
+@echo off
+
+:: verify paths
+if not exist "%MOAI_BIN%\moai.exe" (
+ echo.
+ echo --------------------------------------------------------------------------------
+ echo ERROR: The MOAI_BIN environment variable either doesn't exist or it's pointing
+ echo to an invalid path. Please point it at a folder containing moai.exe.
+ echo --------------------------------------------------------------------------------
+ echo.
+ goto end
+)
+
+if not exist "%MOAI_CONFIG%" (
+ echo.
+ echo -------------------------------------------------------------------------------
+ echo WARNING: The MOAI_CONFIG environment variable either doesn't exist or it's
+ echo pointing to an invalid path. Please point it at a folder containing config.lua.
+ echo -------------------------------------------------------------------------------
+ echo.
+)
+
+:: run moai
+"%MOAI_BIN%\moai" "%MOAI_CONFIG%\config.lua" "main.lua"
+
+:end
+pause

0 comments on commit 1321ffa

Please sign in to comment.