Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jun 12, 2008, 10:53:51 PM (16 years ago)
Author:
landauf
Message:
  • added feature to add a callback function to configvalues. they get called if the value changes. an examples is in Core.cc.
  • changed the SetConfigValue macro and the Identifier::updateConfigValues() function to work properly with inherited classes in both possible cases: 1) they overwrite the config-value or 2) they don't. an example is ParticleProjectile that defines it's own speed_ configvalue.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/core3/src/orxonox/objects/ParticleProjectile.cc

    r1563 r1596  
    3232#include "SpaceShip.h"
    3333#include "core/CoreIncludes.h"
    34 
     34#include "core/ConfigValueIncludes.h"
    3535namespace orxonox
    3636{
     
    5252            this->particles_ = 0;
    5353        }
     54
     55        this->setConfigValues();
    5456    }
    5557
     
    6062    }
    6163
     64    void ParticleProjectile::setConfigValues()
     65    {
     66        SetConfigValue(speed_, 5000.0).description("The speed of a projectile in units per second").callback(&ParticleProjectile::speedChanged);
     67    }
     68
     69    void ParticleProjectile::speedChanged()
     70    {
     71        Projectile::speed_s = this->speed_;
     72        if (this->owner_)
     73            this->setVelocity(this->owner_->getInitialDir() * this->speed_);
     74    }
     75
    6276    void ParticleProjectile::changedVisibility()
    6377    {
Note: See TracChangeset for help on using the changeset viewer.