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


C++ Event::Activate方法代码示例

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


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

示例1:

	void
	MonoTimerPool::SetTick(tick_t tick)
	{
		tick_t tickDelta = tick - mTick;
		while (tickDelta)
		{
			tick_t step = crh_max_step(&mCRH);
			if (step > tickDelta || step == 0)
			{
				step = tickDelta;
				mTick += step;
				crh_set_base(&mCRH, mTick);
						
				break;
			}

			mTick += step;
			tickDelta -= step;
			crh_node_t node = crh_set_base(&mCRH, mTick);

			if (node == NULL) continue;

			crh_node_t cur = node;
			while (1)
			{
				Timer *timer = (Timer *)((uintptr_t)cur - (uintptr_t)(&((Timer *)0)->mNode));

				timer->Lock();
				crh_remove(&mCRH, &timer->mNode);
				timer->mPool = NULL;
				Event *event = timer->mEvent;

				cur->next->prev = cur->prev;
				cur->prev->next = cur->next;
				if (cur == cur->next)
				{
					timer->Unlock();
					event->Activate();
					break;
				}
				else
				{
					cur = cur->next;
					timer->Unlock();
					event->Activate();
				}
			}
		}

		mTick = tick;
		crh_set_base(&mCRH, mTick);
	}
开发者ID:xinhaoyuan,项目名称:muge,代码行数:52,代码来源:timer.cpp

示例2: Update

void Level::Update()
{
	for( int idx = 0; idx < Layers->count; idx++ )
	{
		((Layer*)Layers->ItemAt( idx ))->Update();
	}
	if( Events->count > 0 )
	{
		for( int idx = 0; idx < Events->count; idx++ )
		{
			Event* evnt = (Event*)Events->ItemAt( idx );
			if( evnt->ActivatePosition == ScrollLevelPosition )
			{
				evnt->Activate();
				delete evnt;
				Events->RemoveAt( idx );
				idx--;
			}
		}
	}
	ScrollLevelPosition++;
}
开发者ID:pmprog,项目名称:P01,代码行数:22,代码来源:level.cpp

示例3: LoadLevel

void Level::LoadLevel( char* FileName )
{
	config_t cfg;
	config_setting_t *setting;
	config_setting_t *list;

	config_init(&cfg);
	config_read_file( &cfg, FileName );

	setting = config_lookup( &cfg, "LevelInfo" );

	const char* tmpStr;

	config_setting_lookup_string( setting, "LevelName", &tmpStr );
	LevelName = (char*)malloc( strlen(tmpStr) + 2 );
	sprintf( LevelName, "%s", tmpStr );

	config_setting_t* trackData = config_setting_get_member( setting, "Music" );
	for( int idx = 0; idx < config_setting_length( trackData ); idx++ )
	{
		char* tempElem;
		tmpStr = config_setting_get_string_elem( trackData, idx );
		tempElem = (char*)malloc( strlen(tmpStr) + 2 );
		sprintf( tempElem, "%s", tmpStr );
		MusicTracks->AddToEnd( (void*)tempElem );
	}

	config_setting_lookup_string( setting, "IntroScreenImage", &tmpStr );
	IntroDisplay = (char*)malloc( strlen(tmpStr) + 2 );
	sprintf( IntroDisplay, "%s", tmpStr );

	config_setting_lookup_int( setting, "IntroMusicTrack", &IntroMusicTrack );

	list = config_lookup( &cfg, "Layers" );
	for( int eidx = 0; eidx < config_setting_length( list ); eidx++ )
	{
		Layer* newLayer = new Layer( this, config_setting_get_elem( list, eidx ) );
		Layers->AddToEnd( newLayer );
	}

	list = config_lookup( &cfg, "Events" );
	for( int eidx = 0; eidx < config_setting_length( list ); eidx++ )
	{
		Event* newEvent = new Event( this, config_setting_get_elem( list, eidx ) );
		// Are we a pre-game activation? If so, process and delete
		if( newEvent->ActivatePosition == -1 )
		{
			newEvent->Activate();
			delete newEvent;
		} else {
			Events->AddToEnd( newEvent );
		}
	}

	list = config_lookup( &cfg, "Scripts" );
	for( int eidx = 0; eidx < config_setting_length( list ); eidx++ )
	{
		Uint16* scriptBuffer;
		config_setting_t* scriptArray = config_setting_get_elem( list, eidx );
		scriptBuffer = (Uint16*)malloc( config_setting_length( scriptArray ) * 2 );
		for( int aidx = 0; aidx < config_setting_length( scriptArray ); aidx++ )
		{
			int scriptOpCode;
			scriptOpCode = config_setting_get_int_elem( scriptArray, aidx );

			scriptBuffer[aidx] = (Uint16)(scriptOpCode & 0x0000FFFF);
		}
		Scripts->AddToEnd( (void*)scriptBuffer );
	}

	list = config_lookup( &cfg, "Templates" );
	for( int eidx = 0; eidx < config_setting_length( list ); eidx++ )
	{
		EnemyCraftTemplate* newTemplate = new EnemyCraftTemplate( Owner, config_setting_get_elem( list, eidx ) );
		EnemyTemplates->AddToEnd( newTemplate );
	}

	setting = config_lookup( &cfg, "LayerInfo" );
	config_setting_lookup_int( setting, "CollisionIndex", &LayerCollisionIndex );
	config_setting_lookup_int( setting, "GameIndex", &LayerGameIndex );

	config_destroy(&cfg);
}
开发者ID:pmprog,项目名称:P01,代码行数:83,代码来源:level.cpp


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