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/Projectile.cc

    r1592 r1596  
    4444namespace orxonox
    4545{
    46     float Projectile::speed_ = 5000;
     46    float Projectile::speed_s = 5000;
    4747
    4848    Projectile::Projectile(SpaceShip* owner) : owner_(owner)
     
    7474        SetConfigValue(damage_, 15.0).description("The damage caused by the projectile");
    7575        SetConfigValue(lifetime_, 4.0).description("The time in seconds a projectile stays alive");
    76         SetConfigValue(speed_, 5000.0).description("The speed of a projectile in units per second");
     76        SetConfigValue(speed_, 5000.0).description("The speed of a projectile in units per second").callback(&Projectile::speedChanged);
     77    }
    7778
     79    void Projectile::speedChanged()
     80    {
     81        Projectile::speed_s = this->speed_;
    7882        if (this->owner_)
    7983            this->setVelocity(this->owner_->getInitialDir() * this->speed_);
Note: See TracChangeset for help on using the changeset viewer.