예제 #1
0
RuntimeObject::RuntimeObject(RuntimeScene &scene, const gd::Object &object)
    : name(object.GetName()),
      type(object.GetType()),
      X(0),
      Y(0),
      zOrder(0),
      hidden(false),
      objectVariables(object.GetVariables()) {
  ClearForce();

  behaviors.clear();
  // Insert the new behaviors.
  for (auto it = object.GetAllBehaviors().cbegin();
       it != object.GetAllBehaviors().cend();
       ++it) {
    behaviors[it->first] = std::unique_ptr<gd::Behavior>(it->second->Clone());
    behaviors[it->first]->SetOwner(this);
  }
}
예제 #2
0
RuntimeObject::RuntimeObject(RuntimeScene & scene, const gd::Object & object) :
    name(object.GetName()),
    type(object.GetType()),
    X(0),
    Y(0),
    zOrder(0),
    hidden(false),
    objectVariables(object.GetVariables())
{
    ClearForce();

    //Do not forget to delete behaviors which are managed using raw pointers.
    for (std::map<gd::String, Behavior* >::const_iterator it = behaviors.begin() ; it != behaviors.end(); ++it )
    	delete it->second;

    behaviors.clear();

    //And insert the new ones.
    for (std::map<gd::String, Behavior* >::const_iterator it = object.GetAllBehaviors().begin() ; it != object.GetAllBehaviors().end(); ++it )
    {
    	behaviors[it->first] = it->second->Clone();
    	behaviors[it->first]->SetOwner(this);
    }
}