Jump to content

Anyone give me example of using Actor in CPP


Go to solution Solved by GorzenDev,

Recommended Posts

  • Solution

The BaseActor class i use to derive actors from.
Use it just like you would use a entity script.

Attach actor to a entity.

baseActor = new BaseActor();
entity->SetActor(baseActor);


BaseActor.h


#include "Leadwerks.h"


using namespace Leadwerks;

const enum class ActorType : char { Base, Player, NPC};

class BaseActor : public Actor
{
	//Built-in extendable functions
	//
	//virtual void EndAnimation(const int sequence);
	virtual void Sleep();
	//virtual void Wake();
	virtual void Attach();
	//virtual void Detach();
	//virtual void Collision(Entity* entity, const Vec3& position, const Vec3& normal, float speed);
	virtual void UpdateWorld();
	virtual void UpdatePhysics();
	//virtual void UpdateMatrix();
	virtual void PostRender(Context* context);
	//virtual void Draw();
	//virtual void DrawEach(Camera* camera);
	//virtual void ReceiveSignal(const std::string& inputname, Entity* sender);
public:
	ActorType actorType = ActorType::Base;


	BaseActor();
	virtual ~BaseActor();


};


BaseActor.cpp

#include "BaseActor.h"


BaseActor::BaseActor()
{
}


BaseActor::~BaseActor()
{
}

void BaseActor::Attach()
{
	//
	//System::Print("BaseActor Attached.");
}

void BaseActor::Sleep()
{
	//
	//System::Print("BaseActor Sleep.");
}

void BaseActor::UpdateWorld()
{
	//System::Print("BaseActor UpdateWorld.");
}

void BaseActor::UpdatePhysics()
{
	//System::Print("BaseActor UpdatePhysics.");
}

void BaseActor::PostRender(Context* context)
{
	//
}

 

  • Thanks 1
Link to comment
Share on other sites

1 hour ago, reepblue said:

I can give you one when I get home. What's the issue you are having?

I return to leadwerks cpp learning process and I did not find any example file like in tutorial, so that I can't learn from it

https://www.leadwerks.com/learn?page=Tutorials_CPP_Actors

This should be fixed. or the example code should be put into this tutorial page, maybe Josh is too busy to fix this

 

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...