本文整理汇总了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);
}
示例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++;
}
示例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);
}