示例#1
0
	KVOID BulletFactor::EndTime( KCSTR& sClass,KCSTR& sName, KANY aUserData )
	{
		if (sClass == CLASS_TO(EffectParticle))
		{
			ActivateEffect(sName,false);

			KINT nData = boost::any_cast<KINT>(aUserData);
			if (nData == 1)
			{
				KSTR sEffect;
				if (m_kProperty.GetStrValue("$IdleEffect",sEffect))
					ActivateEffect(sEffect,true);
			}
			else if (nData == 3)
			{
				EventPtr spPosEV(
					KNEW Event(
					&ev_post_destroy, 
					Event::ev_nextframe,
					0, 
					0, 
					NULL
					));

				KylinRoot::GetSingletonPtr()->PostMessage(this->GetID(),spPosEV);
			}
		}
	}
示例#2
0
	KVOID BulletFactor::PostSpawn()
	{
		//Factor::PostSpawn();
		// 激活特效
		KSTR sEffect;
		if (m_kProperty.GetStrValue("$SpawnEffect",sEffect))
			ActivateEffect(sEffect,true);
	}
示例#3
0
	KVOID BulletFactor::OnExplode()
	{
		if (!m_bExplode)
		{
			KSTR sEffect;
			if (m_kProperty.GetStrValue("$DestroyEffect",sEffect))
				ActivateEffect(sEffect,true);

			if (m_kProperty.GetStrValue("$IdleEffect",sEffect))
				ActivateEffect(sEffect,false);

			// 接触地面后速度为0
			m_fVelocity		= .0f;
			m_bExplode		= true;
			m_bNeedCallback = false;

			Kylin::PhyX::PhysicalSystem::GetSingletonPtr()->GetMotionSimulator()->Erase(this);
		}
	}
示例#4
0
void GuiContainer::Draw(void)
{
    Lock();

    LayerTransform transform = GetTransform();

    if( IsVisible() ) {
        // Call ALL registered render callbacks
        for(std::list<GuiContainerCallback>::reverse_iterator rit = render_callback.rbegin(); rit != render_callback.rend(); ++rit) {
            if( (*rit).callback((*rit).context) ) {
              stop_requested = true;
            }
        }

        // Call registered frame callback top-to-bottom
        // stop on first modal frame (return value = true)
        for(std::list<GuiContainerCallback>::reverse_iterator rit = frame_callback.rbegin(); rit != frame_callback.rend(); ++rit) {
            if( (*rit).callback((*rit).context) ) {
                break;
            }
        }
    }

    // Reset transformation of layers
    for(std::list<GuiLayer*>::reverse_iterator rit = layers.rbegin(); rit != layers.rend(); ++rit) {
        GuiLayer *lay = *rit;
        LayerTransform t = transform;
        float posx = lay->GetX();
        float posy = lay->GetY();
        // Rotation transformation
        if( transform.rotation != 0.0f ) {
            float dx = lay->GetX() + lay->GetRefPixelX() - GetRefPixelX();
            float dy = lay->GetY() + lay->GetRefPixelY() - GetRefPixelY();
            float r = (float)sqrt(dx*dx+dy*dy);
            float a = (float)atan2(dy, dx);
            a = (float)fmod(a + (transform.rotation * GUI_2PI / 360.0f), GUI_2PI);
            posx += (float)cos(a) * r - dx;
            posy += (float)sin(a) * r - dy;
        }
        // Zoom transformation
        posx = (posx - GetRefPixelX()) * transform.stretchWidth + GetRefPixelX();
        posy = (posy - GetRefPixelY()) * transform.stretchHeight + GetRefPixelY();
        // Apply
        t.offsetX += posx - lay->GetX();
        t.offsetY += posy - lay->GetY();
        lay->ResetTransform(t);
    }

    // Handle effects
    std::list<LayerEffect>::iterator it = effect_list.begin();
    while( it != effect_list.end() ) {
        LayerEffect ef = *it;
        if( ef.active ) {
            if( ef.effect != NULL ) {
                if( ef.effect->Run() ) {
                    Delete(ef.effect);
                    ef.effect = NULL;
                }
            }
            if( ef.effect == NULL ) {
                // Effect is done, remove from effect list
                effect_list.erase(it++);
                // Activate next effect for the layer (if any)
                ActivateEffect(ef.layer);
                // Do post-effect actions
                if( ef.postaction == EP_REMOVE ) {
                    LayerRemove(ef.layer);
                }
                if( ef.postaction == EP_HIDE ) {
                    ef.layer->SetVisible(false);
                }
                continue;
            }
        }
        it++;
    }

    // Draw layers
    if( IsVisible() ) {
        for(std::list<GuiLayer*>::reverse_iterator rit = layers.rbegin(); rit != layers.rend(); ++rit) {
            (*rit)->Draw();
        }
    }

    Unlock();
}