Jump to content

Accessing objects in editor from C++ code


bkornienko
 Share

Recommended Posts

Hello guys!

I am newbie in this Engine. I would like to ask you for help.

 

I set up small scene with editor where I put a camera and crawler. I have already done couple of tutorials of changing it run-time (and creating it actually runtime). But what if I want to manipulate with objects which I put on editor?

 

How do I do it?

And if you provide some links to resources where I can learn it deeply I would really appreciate it.

Link to comment
Share on other sites

To use C++ you should open Projects\Windows\<your projectname>.sln in Visual Studio and compile.

If you don't want Main.Lua to be executed you can go for a more clean approach and replace main.cpp

with something like this

 

#include "Leadwerks.h"
#include <sstream>

using namespace Leadwerks;

int main(int argc, const char *argv[])
{
   // Initialize Steamworks (optional)
   // Steamworks::Initialize();

   // Create the app window
   Window* window = Window::Create("My Game", 0, 0, 1024, 768, Window::Titlebar);

   // and some context to draw on
   Context* context = Context::Create(window, 0);
   if (context == nullptr)
   {
       return 1;
   }

   // The world containg all objects
   World* world = World::Create();

   // Load a map into the world
   if (!Map::Load( "Maps/start.map" )
   {
       return 2;
   }

   // Loop until window is closed or user presses ESCAPE
   bool showstats = false;
   while (!window->KeyDown(Key::Escape) && !window->Closed())
   {
       Time::Update();
       world->Update();
       world->Render();

       context->SetBlendMode(Blend::Alpha);
       showstats = window->KeyHit(Key::F11) ? !showstats : showstats;
       if (showstats)
       {
           ostringstream fps;
           fps << "FPS: " << Math::Round(Time::UPS());
           context->SetColor(1, 0, 0, 1);
           context->DrawText("Debug Mode", 2, 2);
           context->SetColor(1, 1, 1, 1);
           context->DrawText(fps.str(), 2, 2);
           context->DrawStats(2, 22);
           context->SetBlendMode(Blend::Solid);
       }

       context->Sync(true);
   }

   return 0;
}

Roland Strålberg
Website: https://rstralberg.com

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