I have an EnemyBullet subclass of superclass Bullet. Now I'm calling the Bullet method Process() using an EnemyBullet object. What I want is to determine whether the current object is an EnemyBullet to distinguish from Bullet action. My code is like this,
void Bullet::Process(float deltaTime)
{
// Generic position update, based upon velocity (and time).
m_y = m_y + this->GetVerticalVelocity()*deltaTime;
m_pSprite->SetY(static_cast<int>(m_y));
m_pSprite->SetX(static_cast<int>(m_x));
if (m_y < 0)
{
SetDead(true);
}
//Here I want to detect current object is an EnemyBullet, then define a different action
//I tried the following code, but it didn't work
if (EnemyBullet* v = static_cast<EnemyBullet*>(Bullet)) {
if (m_y >800)
{
SetDead(true);
}
}
}
Aucun commentaire:
Enregistrer un commentaire