wdl7770016

Members
  • Content count

    8
  • Joined

  • Last visited

Community Reputation

104 Neutral

About wdl7770016

  • Rank
    Newbie
  1. the error report tell me : There is no copy operator for the type 'Entity' available. What should I do? register a copy behaviour?but I don't find a Enum like asBEHAVE_COPY.... and mannual is no say how to do it....maybe just I not find it help me -0 -please XD
  2. I  want to register a const unsigned int value but the enum is only support int type so I can't use it finally I only could use RegisterGlobalProperty but it can't recieve a const value ....How can I do it ?
  3. thanks  I have learned a lot
  4. why I can't call a script member function successfully?

      thanks  I have resolve it now
  5. I use this in my work:   asIScriptModule *mod = Stage::getInstance()->getScriptModule()->getBuilder()->GetModule(); asIObjectType *type = Stage::getInstance()->getScriptModule()->getEngine()->GetObjectTypeById(mod->GetTypeIdByDecl(behaviourClassName.c_str())); //??????????????? if (type == 0 ) { return 0; } //????IBehaviour??? IBehaviour *iBehaviour = Stage::getInstance()->getScriptModule()->getIBehaviour(); //???????????IBehaviour if (!iBehaviour->isImplementBy(type)) { return 0; } //????????? string factoryDecl = behaviourClassName + " @" + behaviourClassName + "()"; asIScriptFunction *factoryFunc = type->GetFactoryByDecl("XXXBehaviour @XXXBehaviour()"); if (factoryFunc == 0) { return 0; } asIScriptContext *context = Stage::getInstance()->getScriptModule()->getAvailableContext(); context->Prepare(factoryFunc); context->Execute(); asIScriptObject *obj = *(asIScriptObject **)context->GetAddressOfReturnValue(); if (obj == 0) { return 0; } //?????????Id(?????????????????????????IBehaviour??? asIScriptFunction *func_getType = type->GetMethodByDecl("uint getType()"); context->Prepare(func_getType); context->SetObject(obj); context->Execute(); BEHAVIOUR_TYPE bType = context->GetReturnDWord(); cout << "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" << bType << endl; return 0; I register a IBehaviour interface to the engine _engine->RegisterInterface("IBehaviour"); _engine->RegisterInterfaceMethod("IBehaviour", "uint getType()"); I instance the XXXBehaviour and want to call it's getType method which is in IBehaviour this is script code: class XXXBehaviour : IBehaviour { XXXBehaviour() {} uint getType() { return 110; } int getInt() { print("kfc"); return 120; } } but it will work only when I comment the "context->SetObject(obj);" and through it work but the bType is still be 0, because in fact it may not work please help me  thanks
  6. well thanks but is this means before we register the reciever function we can add a new section from file A or memory(string) so that engine can pass the script code and know the script class declared in file A and when we register the reciever function the engine had know the script class type I have try this  but it not work  it's so strange>>>right?
  7. thanks but there are something like this in the angelScript mannual: Of course, since the class is declared in the script it isn't possible to know the type before the script is compiled. but I can't work it successfully is this because of angelScript does not support reciever a script class thich declared in the as script file?
  8. this is my c++ code: class Base { public: Base() { _refCount = 1; cout << "Base Create" << endl; } void addRef() { _refCount++; } void release() { _refCount--; if (_refCount == 0) { delete this; } } void reciever(asIScriptObject *obj) { cout << "???" << endl; man = obj; } void active() { cout << "??Active" << endl; cout << (man == 0) << endl; cout << "??Active" << endl; } private: int _refCount; asIScriptObject *man; }; Base *Base_Factory() { return new Base(); } ...... //--------------------------------------------------------- scriptEngine->RegisterObjectType("Base", 0, asOBJ_REF); scriptEngine->RegisterObjectBehaviour("Base",asBEHAVE_FACTORY, "Base@ f()", asFUNCTION(Base_Factory), asCALL_CDECL); scriptEngine->RegisterObjectBehaviour("Base", asBEHAVE_ADDREF, "void f()", asMETHOD(Base, addRef), asCALL_THISCALL); scriptEngine->RegisterObjectBehaviour("Base", asBEHAVE_RELEASE, "void f()", asMETHOD(Base, release), asCALL_THISCALL); //--------------------------------------------------------- CScriptBuilder builder; r = builder.StartNewModule(scriptEngine, "MyModule"); int isOK = builder.AddSectionFromFile("init.as"); asIObjectType *type = scriptEngine->GetObjectTypeByName("Human"); cout << "type == " << (type == 0) << endl; //r = builder.AddSectionFromFile("test.as"); r = builder.BuildModule(); scriptEngine->RegisterObjectMethod("Base", "void reciever(Human @in)", asMETHOD(Base, reciever), asCALL_THISCALL); scriptEngine->RegisterObjectMethod("Base", "void active()", asMETHOD(Base, active), asCALL_THISCALL); ........ and in my init.as script code: class Human { Human(){} } but it is still report a error: Failed in call to function 'RegisterObjectMethod' with 'Base' and 'void reciever(Human @in)' (code: -10) why ?  may it must to reciever a interface nor a script class?