Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changes between Version 5 and Version 6 of code/howto/Synchronisable


Ignore:
Timestamp:
Sep 25, 2008, 9:42:54 PM (16 years ago)
Author:
scheusso
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • code/howto/Synchronisable

    v5 v6  
    3434}
    3535}}}
     36 6. Call the create function from within XMLPort (see [wiki:XMLPort]):
     37{{{
     38void XYZ::XMLPort(...){
     39  ...
     40  XYZ::create();
     41}
     42}}}
    3643== Multidirectional synchronisation ==
    3744If you want to have a variable synchronised back to the server, follow these steps (additional to/instead of the above):
     
    5158}
    5259}}}
     60== Example class ==
     61{{{
     62#include "network/Synchronisable.h"
     63
     64class myFancyObject : public network::Synchronisable
     65{
     66private:
     67  //Membervariables
     68  std::string myString_;
     69  Ogre::SceneNode* node_;
     70
     71  //Memberfunctions
     72  void registerAllVariables(){
     73    REGISTERDATA_WITHDIR(node_->getPosition().x, network::direction::bidirectional);
     74    REGISTERDATA_WITHDIR(node_->getPosition().y, network::direction::bidirectional);
     75    REGISTERDATA_WITHDIR(node_->getPosition().z, network::direction::bidirectional);
     76    REGISTERSTRING(myString_);
     77  }
     78public:
     79  myFancyObject(){
     80    node_ = new Ogre::SceneNode;
     81    registerAllVariables();
     82    setObjectMode(network::direction::bidirectional);
     83  }
     84  ~myFancyObject(){}
     85  bool create(){
     86    // do some stuff here
     87  }
     88  void XYZ::XMLPort(...){
     89    ...
     90    XYZ::create();
     91  }
     92
     93 
     94}
     95
     96}}}