Jump to content

C++ Trigger


MexSource
 Share

Recommended Posts

Hey,

 

I already created some triggers with leadwerks 3.0 but now in 3.1 i have one problem.

It says: invalid type conversion

at this line: currEnt->AddHook(Entity::CollisionHook, (void*)onCollision);

 

heres my App.h:

 

#pragma once
#include "Leadwerks.h"
using namespace Leadwerks;
class App
{
public:
Leadwerks::Window* window;
Context* context;
World* world;
Camera* camera;
App();
virtual ~App();

void onCollision(Entity* entity0, Entity* entity1, float* position, float* normal, float speed);
   virtual bool Start();
   virtual bool Loop();
};

 

and the important part of my App.cpp

 

[...]
//The onCollision function
void onCollision(Entity* entity0, Entity* entity1, float* position, float* normal, float speed){
}
[...]
//and in App::Start
[...]
list<Entity*>::iterator iter;
for (iter = world->entities.begin(); iter != world->entities.end(); ++iter){
 Entity* currEnt = (*iter);
 cout << "Entity loaded: " + currEnt->GetKeyValue("name") << endl;
 if (currEnt->GetKeyValue("name") == "runner_spawn"){
  runner_spawn = currEnt->GetPosition();
 }
 if (currEnt->GetKeyValue("name") == "death_spawn"){
  death_spawn = currEnt->GetPosition();
 }
 if (currEnt->GetKeyValue("name") == "runner_mesh"){
  runner_mesh = currEnt;
 }
 if (currEnt->GetKeyValue("name") == "death_mesh"){
  death_mesh = currEnt;
 }
 if (currEnt->GetKeyValue("name") == "void"){
  currEnt->AddHook(Entity::CollisionHook, (void*)onCollision);
 }
}
[...]

 

if you need more code i will give it out, but i think that should be enough

 

Thanks,

Mex :)

C++ :3

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...