TheConceptBoy Posted June 9, 2019 Share Posted June 9, 2019 Good day, I am writing this in hopes that after 4 minutes of posting this extensive question, I figure it out on my own. So apparently Leadwerks Actors system. from what I understand is an arbitrary method of creating classes that offer better integration within the engine than ordinary classes. If created properly, things like the main loop, creation and what not get executed automatically, saving you the trouble of creating your own main loop and putting in the code to update the main loop of the class yourself manually. I'm experimenting with say a class of zombies. In several locations, it's been said that when you are creating your own actor class, it should be based on the existing actor class generated by Leadwerks. I created a blank LW project and no such class was present in the project files. Furthermore, the docs outline that you use that existing class to create your own actor classes using inheritance. However once more there were no examples of how to achieve the mentioned inheritance. I did note that when you create a class in VS, it asks for a Base Class: Is this what the docs mean by creating a class based on the default one? So I went with an assumption that I just need to include a few things when I create a class in order to make sure Leadwerks can trigger it's functions or Hooks as peeps call them. So my zombie.h #include "Leadwerks.h" using namespace Leadwerks; class zombie { public: zombie(); ~zombie(); void Attach(); void Detach(); //void Collision(Entity* entity, const Vec3& position, const Vec3& normal, float speed); void UpdateWorld(); void UpdatePhysics(); void UpdateMatrix(); //void PostRender(Context* context); void Draw(); //void DrawEach(Camera* camera); }; zombie.cpp #include "zombie.h" zombie::zombie() { } zombie::~zombie() { } void zombie::Attach() { } void zombie::UpdateWorld() { System::Print("BaseActor UpdateWorld."); } I have no idea WHERE it want's that damn semi in the code, However if I move the zombie::Attach() function AFTER update world, the error goes away. While it may fix the issue, I would still like to know why it's complaining in the first place so that perhaps I may have a clue next time. in the Main function before the application enters a loop, I get this: now Everywhere (Forum, Docs etc) I see people doing this: No need to create the actor variable using the class like BaseActor * baseActir = new BaseActor(); in order to store the new instance of object and same thing with entity. Where is this entity coming from? There's no Entity::Create() in the docs so I have no idea why it's complaining here. Appreciate all the help I can get. Quote Link to comment Share on other sites More sharing options...
SpiderPig Posted June 9, 2019 Share Posted June 9, 2019 Have you defined zombie_001 and entity somewhere? like; zombie* zombie_001 = nullptr; Entity* entity = nullptr; 1 Quote Link to comment Share on other sites More sharing options...
SpiderPig Posted June 9, 2019 Share Posted June 9, 2019 Also to use the Actor system your class needs to derive from it; class zombie : public Actor { ... 1 Quote Link to comment Share on other sites More sharing options...
TheConceptBoy Posted June 9, 2019 Author Share Posted June 9, 2019 Ah, ok, making progress. Would you know why in the zombie.cpp the UpdateWorld is complaining about a semicolon, and that it fixes itself by just moving the function above the Attach function? Both functions are empty and I don't think the order of function declaration in the .h file affects it. Also the semicolon issue has moved on to here and I know for a fact that the issue is not somewhere above as when I delete these two lines, the application compiles just fine. Quote Link to comment Share on other sites More sharing options...
SpiderPig Posted June 9, 2019 Share Posted June 9, 2019 No I'm not sure about that one. I can't see anything obviously wrong with it. Have you tried moving it back beneath Attach() function after you made the zombie class drive from Actor? Quote Link to comment Share on other sites More sharing options...
TheConceptBoy Posted June 9, 2019 Author Share Posted June 9, 2019 1 minute ago, Lethal Raptor Games said: No I'm not sure about that one. I can't see anything obviously wrong with it. Have you tried moving it back beneath Attach() function after you made the zombie class drive from Actor? yeah that same semicolon error in the main.cpp remains. Quote Link to comment Share on other sites More sharing options...
SpiderPig Posted June 9, 2019 Share Posted June 9, 2019 You need to create an entity object first; Entity* entity = Entity::Box(); entity->SetActor(zombie_001); Quote Link to comment Share on other sites More sharing options...
TheConceptBoy Posted June 9, 2019 Author Share Posted June 9, 2019 1 minute ago, Lethal Raptor Games said: You need to create an entity object first; Entity* entity = Entity::Box(); entity->SetActor(zombie_001); I don't think there is such a thing as: Entity* entity = Entity::Box(); If there is, it's not in the Docs. https://www.leadwerks.com/learn?page=API-Reference_Object_Entity There does not appear to be a Create() or a Box() for Entities. There is a Create for various things that are derived from Entity like Camera, Model, Light, Decal, Emitter Quote Link to comment Share on other sites More sharing options...
SpiderPig Posted June 9, 2019 Share Posted June 9, 2019 Sorry, Model::Box(). 1 Quote Link to comment Share on other sites More sharing options...
TheConceptBoy Posted June 9, 2019 Author Share Posted June 9, 2019 Ok, on the side note, I've declared a whole bunch of functions in the .h file however I did not specify them in the cpp file for the zombie. Not that it changed anything, just a flashback from my last hair ripping C++ experience: Currently my cpp file looks like this: I'd like to point out that the ; error you see for the void of UpdateWorld is, I'm certain, is caused by the Attach function because if I move that function after UpdateWorld, then Detach will get that error so something is up with Attach. EDIT: as the matter of fact. I can remove Attach and it will move the error to Detach, then deleting that makes it move to another function so yeah. And the header is : Quote Link to comment Share on other sites More sharing options...
TheConceptBoy Posted June 9, 2019 Author Share Posted June 9, 2019 Also in addition to the above issue. Can you see if I understand these functions correctly? void Attach(); Is called during instance creation / attachment to an entity, it's a single shot event. void Detach(); Called when instance is destroyed / detatched from the Entity and the engine handle removal of all things related to it automatically. void Collision(Entity* entity, const Vec3& position, const Vec3& normal, float speed); Called upon collision with another instance. void UpdateWorld(); The main loop for this particular instance, called every cycle. void UpdatePhysics(); ? void UpdateMatrix(); ? void PostRender(Context* context); void Draw(); Called during drawing stage of the loop, perfect place for using the draw commands like void DrawEach(Camera* camera); ? Quote Link to comment Share on other sites More sharing options...
SpiderPig Posted June 9, 2019 Share Posted June 9, 2019 I have had errors like that before, saying I need to insert a semicolon but it has never been the case. Usually there was a semicolon missed somewhere either in the cpp or header files. he only difference I see between my actor code and yours is mine has a private member, and the functions derived from Actor are declared as virtual. class BaseActor : public Actor { private: public: BaseActor(); ~BaseActor(); virtual void UpdateWorld(); }; Not sure if it will make a difference though. virtual void Attach() Single event possible when a script is attached? virtual void Detach() As above but when removed? virtual void UpdateWorld() Per game loop virtual void UpdatePhysics() Per physics loop virtual void UpdateMatrix() Called when the rotation, translation and scale of an entity is changed (i.e. its matrix). virtual void Collision(Entity* entity, const Vec3& position, const Vec3& normal, float speed) On a collision. virtual void PostRender(Context* context) Place drawing commands here (DrawImage etc.) virtual void DrawEach(Camera* camera) Not sure, but could be if the object has been rendered by more than one camera, this may be called for each camera virtual void Draw() I think this is called when the entity is rendered. 1 Quote Link to comment Share on other sites More sharing options...
TheConceptBoy Posted June 9, 2019 Author Share Posted June 9, 2019 Would you mind sharing the acompanying cpp file you have for baseActor? I'm comparing the contents Quote Link to comment Share on other sites More sharing options...
SpiderPig Posted June 9, 2019 Share Posted June 9, 2019 Yeah I'll post it. I just had a thought, are you calling #pragma once at the top of your header file? BaseActor.cpp BaseActor.h Quote Link to comment Share on other sites More sharing options...
TheConceptBoy Posted June 9, 2019 Author Share Posted June 9, 2019 1 minute ago, Lethal Raptor Games said: Yeah I'll post it. I just had a thought, are you calling #pragma once at the top of your header file? BaseActor.cpp 3.73 kB · 0 downloads BaseActor.h 1.28 kB · 0 downloads I was, then I deleted it, just to see what happens, now added it. Appears to not be the cause of the issue, something else is still up with this. Quote Link to comment Share on other sites More sharing options...
SpiderPig Posted June 9, 2019 Share Posted June 9, 2019 Interesting. Does it compile and run at all? Quote Link to comment Share on other sites More sharing options...
TheConceptBoy Posted June 9, 2019 Author Share Posted June 9, 2019 I get this array of errors, mainly for the cpp file: Quote Severity Code Description Project File Line Suppression State Error (active) E0077 this declaration has no storage class or type specifier LW_EZPZLMSQ C:\Users\DEVELOPMENT2\Documents\Leadwerks\Projects\LW_EZPZLMSQ\Source\zombie.cpp 15 Error (active) E0065 expected a ';' LW_EZPZLMSQ C:\Users\DEVELOPMENT2\Documents\Leadwerks\Projects\LW_EZPZLMSQ\Source\zombie.cpp 17 Warning D9035 option 'Gm' has been deprecated and will be removed in a future release LW_EZPZLMSQ C:\Users\DEVELOPMENT2\Documents\Leadwerks\Projects\LW_EZPZLMSQ\Projects\Windows\cl 1 Error C2144 syntax error: 'void' should be preceded by ';' LW_EZPZLMSQ c:\users\development2\documents\leadwerks\projects\lw_ezpzlmsq\source\zombie.cpp 16 Error C4430 missing type specifier - int assumed. Note: C++ does not support default-int LW_EZPZLMSQ c:\users\development2\documents\leadwerks\projects\lw_ezpzlmsq\source\zombie.cpp 16 Error C2144 syntax error: 'void' should be preceded by ';' LW_EZPZLMSQ c:\users\development2\documents\leadwerks\projects\lw_ezpzlmsq\source\zombie.cpp 18 Error C4430 missing type specifier - int assumed. Note: C++ does not support default-int LW_EZPZLMSQ c:\users\development2\documents\leadwerks\projects\lw_ezpzlmsq\source\zombie.cpp 18 Error C2086 'int ': redefinition LW_EZPZLMSQ c:\users\development2\documents\leadwerks\projects\lw_ezpzlmsq\source\zombie.cpp 18 Error C1004 unexpected end-of-file found LW_EZPZLMSQ c:\users\development2\documents\leadwerks\projects\lw_ezpzlmsq\source\zombie.cpp 25 Quote Link to comment Share on other sites More sharing options...
SpiderPig Posted June 9, 2019 Share Posted June 9, 2019 Can you upload your .h and .cpp files? Quote Link to comment Share on other sites More sharing options...
TheConceptBoy Posted June 9, 2019 Author Share Posted June 9, 2019 zombie.hzombie.cpp I've tried playing around with setting the functions as public, as per yours and some other posts with suggestions. Quote Link to comment Share on other sites More sharing options...
SpiderPig Posted June 9, 2019 Share Posted June 9, 2019 I don't get it, it doesn't compile for me either. Maybe there is something wrong with those files somehow. Try deleting the files completely then start again. Quote Link to comment Share on other sites More sharing options...
TheConceptBoy Posted June 9, 2019 Author Share Posted June 9, 2019 1 minute ago, Lethal Raptor Games said: I don't get it, it doesn't compile for me either. Maybe there is something wrong with those files somehow. Try deleting the files completely then start again. Haha. Ouch. Ok. Going to check that again. Quote Link to comment Share on other sites More sharing options...
TheConceptBoy Posted June 9, 2019 Author Share Posted June 9, 2019 Now these files have to be in the /Source folder, right? VS Seems to always create them in the Windows project folder where the solution is sitting. i have to move them to source manually. Quote Link to comment Share on other sites More sharing options...
SpiderPig Posted June 9, 2019 Share Posted June 9, 2019 Yeah if they are being referenced by any headers/source files in the Source directory, then they have to be there too. I just moved all my source and header files to the Solution directory so every time I created a new file through VS I didn't have to manually move it to the Source folder. Quote Link to comment Share on other sites More sharing options...
SpiderPig Posted June 9, 2019 Share Posted June 9, 2019 I just got mine to compile... see if they work for you zombie.cpp zombie.h Quote Link to comment Share on other sites More sharing options...
TheConceptBoy Posted June 9, 2019 Author Share Posted June 9, 2019 3 minutes ago, Lethal Raptor Games said: Yeah if they are being referenced by any headers/source files in the Source directory, then they have to be there too. I just moved all my source and header files to the Solution directory so every time I created a new file through VS I didn't have to manually move it to the Source folder. You'd think that if you right click on the Source folder in the Solution explorer and create a class, it would be created in that folder... but noooo 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.