当前位置: 首页>>代码示例>>C++>>正文


C++ MOAILuaState::GetTop方法代码示例

本文整理汇总了C++中MOAILuaState::GetTop方法的典型用法代码示例。如果您正苦于以下问题:C++ MOAILuaState::GetTop方法的具体用法?C++ MOAILuaState::GetTop怎么用?C++ MOAILuaState::GetTop使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MOAILuaState的用法示例。


在下文中一共展示了MOAILuaState::GetTop方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: _setClearColor

/**	@name	setClearColor
	@text	At the start of each frame the device will by default automatically render a background color.  Using this function you can set the background color that is drawn each frame.  If you specify no arguments to this function, then automatic redraw of the background color will be turned off (i.e. the previous render will be used as the background).

	@overload

		@opt	number red			The red value of the color.
		@opt	number green		The green value of the color.
		@opt	number blue			The blue value of the color.
		@opt	number alpha		The alpha value of the color.
		@out	nil
	
	@overload
	
		@in		MOAIColor color
		@out	nil
*/
int MOAIGfxDevice::_setClearColor ( lua_State* L ) {

	MOAILuaState state ( L );
	MOAIGfxDevice& device = MOAIGfxDevice::Get ();
	
	MOAIColor* color = state.GetLuaObject < MOAIColor >( 1 );
	if ( color ) {
		device.SetClearColor ( color );
		device.mClearFlags |= GL_COLOR_BUFFER_BIT;
		return 0;
	}
	
	// don't clear the color
	device.mClearFlags &= ~GL_COLOR_BUFFER_BIT;
	device.SetClearColor ( 0 );

	if ( state.GetTop () > 0 ) {
	
		float r = state.GetValue < float >( 1, 0.0f );
		float g = state.GetValue < float >( 2, 0.0f );
		float b = state.GetValue < float >( 3, 0.0f );
		float a = state.GetValue < float >( 4, 1.0f );
		
		device.mClearColor = USColor::PackRGBA ( r, g, b, a );
		device.mClearFlags |= GL_COLOR_BUFFER_BIT;
	}
	return 0;
}
开发者ID:joarb,项目名称:moai-beta,代码行数:44,代码来源:MOAIGfxDevice.cpp

示例2: SetRef

//----------------------------------------------------------------//
void MOAILuaRef::SetRef ( MOAILuaState& state, int idx, bool weak ) {

	this->Clear ();
	this->mWeak = weak;

	int top = state.GetTop ();
	UNUSED ( top );
	if ( lua_isnil ( state, idx ) == false ) {

		MOAILuaRuntime& luaRuntime = MOAILuaRuntime::Get ();

		if ( weak ) {
			this->mRef = luaRuntime.mWeakRefTable.Ref ( state, idx );
		}
		else {
			this->mRef = luaRuntime.mStrongRefTable.Ref ( state, idx );	
		}
		
		this->mOwnsRef = true;
	}
	
	assert ( top == state.GetTop ());
}
开发者ID:SimonRen,项目名称:moai-beta,代码行数:24,代码来源:MOAILuaRef.cpp

示例3: SetValue

//----------------------------------------------------------------//
void MOAIEnvironment::SetValue ( lua_State* L ) {

	MOAILuaState state ( L );

	int top = state.GetTop ();

	this->PushLuaClassTable ( state );
		
	state.CopyToTop ( -3 ); // key
	state.CopyToTop ( -3 ); // value
	
	lua_settable ( state, -3 );
	state.Pop ( 1 );
	
	if ( this->PushListener ( EVENT_VALUE_CHANGED, state )) {
	
		state.CopyToTop ( -3 ); // key
		state.CopyToTop ( -3 ); // value
		
		state.DebugCall ( 2, 0 );
	}
	
	top = state.GetTop ();
}
开发者ID:Chenhx,项目名称:moai-dev,代码行数:25,代码来源:MOAIEnvironment.cpp

示例4: PushMemberTable

//----------------------------------------------------------------//
bool MOAILuaObject::PushMemberTable ( MOAILuaState& state ) {

	int top = state.GetTop ();

	if ( this->PushLuaUserdata ( state )) {
		if ( lua_getmetatable ( state, -1 )) {
			lua_replace ( state, -2 );
			if ( lua_getmetatable ( state, -1 )) {
				lua_replace ( state, -2 );
				return true;
			}
		}
	}
	state.SetTop ( top );
	lua_pushnil ( state );
	return false;
}
开发者ID:Limingming2,项目名称:meyume-moai-1-6,代码行数:18,代码来源:MOAILuaObject.cpp

示例5: _areaForCircle

/**	@name	areaForCircle
	@text	Returns the area for a ring or circle.
	
	@overload
	
		@in		number radius
		@out	number area

	@overload
	
		@in		number innerRadius
		@in		number outerRadius
		@out	number area
*/ 
int MOAICpShape::_areaForCircle ( lua_State* L ) {
	MOAILuaState state ( L );
	if ( !state.CheckParams ( 1, "N" )) return 0;

	cpFloat r1;
	cpFloat r2;

	if ( state.GetTop () >= 2 ) {
		r1 = state.GetValue < cpFloat >( 1, 0 );
		r2 = state.GetValue < cpFloat >( 2, 0 );
		
	}
	else {
		r1 = 0;
		r2 = state.GetValue < cpFloat >( 1, 0 );
	}

	lua_pushnumber ( L, cpAreaForCircle ( r1, r2 ));
	return 1;
}
开发者ID:AzureRodrigo,项目名称:moai-dev,代码行数:34,代码来源:MOAICpShape.cpp

示例6: DrawLuaParams

//----------------------------------------------------------------//
void MOAIDraw::DrawLuaParams ( lua_State* L, u32 primType ) {

	MOAIGfxDevice& gfxDevice = MOAIGfxDevice::Get ();
	MOAILuaState state ( L );

	u32 total = state.GetTop () >> 1;
	
	gfxDevice.BeginPrim ( primType );
	
	for ( u32 i = 0; i < total; ++i ) {
		
		u32 idx = ( i << 1 ) + 1;
		
		float x = state.GetValue < float >( idx, 0.0f );
		float y = state.GetValue < float >( idx + 1, 0.0f );
		
		gfxDevice.WriteVtx ( x, y, 0.0f );
		gfxDevice.WriteFinalColor4b ();
	}
	
	gfxDevice.EndPrim ();
}
开发者ID:LOFI,项目名称:moai-dev,代码行数:23,代码来源:MOAIDraw.cpp

示例7: PushMemberTable

//----------------------------------------------------------------//
bool MOAILuaObject::PushMemberTable ( MOAILuaState& state ) {

	MOAILuaClass* luaType = this->GetLuaClass ();
	if ( luaType->IsSingleton ()) {
		this->PushLuaClassTable ( state );
		return true;
	}

	int top = state.GetTop ();

	if ( this->PushLuaUserdata ( state )) {
		if ( lua_getmetatable ( state, -1 )) {
			lua_replace ( state, -2 );
			if ( lua_getmetatable ( state, -1 )) {
				lua_replace ( state, -2 );
				return true;
			}
		}
	}
	state.SetTop ( top );
	lua_pushnil ( state );
	return false;
}
开发者ID:,项目名称:,代码行数:24,代码来源:

示例8: MakeLuaBinding

//----------------------------------------------------------------//
void MOAILuaObject::MakeLuaBinding ( MOAILuaState& state ) {

	// stack:
	// -1: interface table
	// -2: member table
	// -3: ref table
	// -4: userdata

	int top = state.GetTop ();
	int memberTable = top - 1;
	int refTable = top - 2;

	// ref table gets gc and tostring
	lua_pushcfunction ( state, MOAILuaObject::_gc );
	lua_setfield ( state, refTable, "__gc" );
	
	lua_pushcfunction ( state, MOAILuaObject::_tostring );
	lua_setfield ( state, refTable, "__tostring" );
	
	// ref table gets 'moai' tag set to true
	lua_pushboolean ( state, 1 );
	lua_setfield ( state, refTable, MOAI_TAG );
	
	
	// member table is __index and __newindex for ref table
	lua_pushvalue ( state, memberTable );
	lua_setfield ( state, refTable, "__index" );
	
	lua_pushvalue ( state, memberTable );
	lua_setfield ( state, refTable, "__newindex" );
	
	// build the metatable stack
	lua_setmetatable ( state, -2 ); // interface is meta of member
	lua_setmetatable ( state, -2 ); // member is meta of ref
	lua_setmetatable ( state, -2 ); // ref is meta of userdata
}
开发者ID:,项目名称:,代码行数:37,代码来源:


注:本文中的MOAILuaState::GetTop方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。