I develop a game using Unreal Engine And I want to investigate the engine source code execution flow, so I want to add breakpoint specific class.
How to add breakpoint to all class's member function in rider?
Related
Its my first c++ program and I am trying to start with the right foot. I have set up C++CLR Winforms in visual studio 2017 and created a new project.
Inside this Project I have my Form1 with a Label. I am able to edit this label from code from inside my form1.cpp.
Now, I would like to have my program in the background and have the form as a interface to the user, thus, I would like to avoid putting all the relevant code inside the form. For example, If i code a simple counter, that displays the value, I do not want to have the counter inside my cpp file. I would like to have it in my main(), and use the form just do display the value.
now, there are a few questions raising with this:
is the main() the one i find in 'sourcefiles/CppCLR_WinformsProject.cpp/main()'?
is it even a good idea to put things into the main() or should it stay empty and would I have to put my code in separate classes?
how can I access the label1 on form1 from the main or any other given class?
Any help appreciated.
I have looked this question up so many times that I am convinced I am missing a huge piece of the puzzle when it comes to integrating LUA into my C++ Game Engine. What I want to do is run my game engine, then while its running I would like to click on my ui and click "add script" and then run the script. That part is easy enough to do but what I DON'T get is how a script that seemingly gets ran in place with lua_dofile could have code that gets mouse input or moves the character based on input. I don't see anyway to do this effectively. Am I supposed to allow the LUA state to be created and destroyed every frame or do I make the script fire every frame? In an application like this:
void init();
void update();
void render();
void end();
How would I use LUA to control the movement of an entity.
Lets say I set up the lua state so that you can write lua code like this:
entity1 = Entity.new()
entity1:setPosition(4,5)
How would I give the script some input from mouse to move the entity to the mouse position?
My overarching question is what is the best way to have a script control my entities in a way that if I supply the Lua State the ability to move my entities, then a scripter could write a "game" (i.e. a interactive runtime application)
To give a concrete example, suppose you wanted to teleport a ball to the player whenever they click the mouse. Here's what you could write to do that in Lua:
local function clickHandler(event)
local x, y, z = event.player:getCoords()
local ball = event.world:getBall()
ball:teleportTo(x, y, z)
end
game.registerEventHandler('click', clickHandler)
To make that example actually work in your engine, here's what you'd need to do:
Create a registerEventHandler function that saves the given callback somewhere C can access it
Create a getCoords function that returns the coordinates of a given player
Create a getBall function that gets a ball in your gameworld
Create a teleportTo method that teleports an entity to a given location
Whenever a player clicks the mouse, run all click event handlers that you saved, with an event object containing the player and the gameworld
And as for this question in particular:
Am I supposed to allow the LUA state to be created and destroyed every frame or do I make the script fire every frame?
No. You create a lua_State when your game starts, load the scripts in it, and then just keep using that state to call the event handlers.
Essentially the Lua scripts define functions to be called at each event. So the host C++ loads the scripts and then enters its main loop and calling back Lua.
See how LÖVE does it.
I know how to debug a console program, but what if the program has a GUI?
For example, there is a Calc icon, when I push it down, it will call some methods.
I want to know what methods it will call. I have the source codes but have no idea about which file corresponds to what, and want to back-track what codes it will implement if I click on the icon.
There conceptually isn't any difference between debugging a GUI application and a console application - they both come down procedural programming - some action calls a particular function. There's no difference whether the trigger of the action is you pressing a button on the GUI, or typing in a command in the console. You can use a debugger for both of them (visual or command line).
If you have the source, and know what the triggering mechanism is, it should be easy enough to follow along in the source code to see which functions are called by the trigger (eg. not at runtime). You have the question tagged as Qt, which uses the connect function to connect 'signals' (events) to either other signals or 'slots'. This is essentially associates a callback function, with a particular event, so searching your source for that would be a good starting place.
I´m trying to put a together a small level system for my game. I want a update method that takes care of my game main logic. So I declared a method in my parent class .h file:
Level.h:
-(void)gameLogicTick:(ccTime)dt;
Then I do the implementation in Level.m, don´t think the exact code is relevant.
I created a subclass of Level called Forest. In the Forest init-method I would like to specify the interval of gameLogicTick, I did this:
[self schedule:#selector(gameLogicTick:)interval:5.0f];
This makes my game crash(after 5 seconds) with no debug message what so ever.
So how can I create a schedule update-method where I can specify the interval in the current class?
What you do is ok. Perhaps the Forest object got deallocated (ie because it was never added as child to a parent node for example) and the next time CCScheduler updates the scheduled methods, it will try to run your method on an already released instance.
You should enable the global exception breakpoint in Xcode to get more crash info and the exact line where the crash occurs.
Don't try messing with the parent class gameLogicTick: method. Leave that one to do its thing at full speed. In your Forest.m, simply call
[self schedule:#selector(update:) interval: 5.0f];
then make sure you have the appropriate update:(ccTime) delta in your Forest implementation. Just don't name it the same as your parent class's method and you won't have any problems.
In my C++ code, I create an instance of a Java class through JNI. That Java class's job is to create a WebView dynamically that should go on top of the application's views.
My current strategy is to retrieve the application's main activity, dynamically create a WebView and attach it to the main activity's list of views. Is this possible? Is it better to create an activity?
This functionality is meant for a standalone library that clients can use. So unfortunately it can't be part of the main application's activity.
At minimum, is it possible to retrieve the application's main activity from an unrelated Java class?
In the end, my Java class has a static method Init that is called by my activity to store the reference to the activity. Later, when my C++ code creates an instance of the Java class it retrieves that reference and uses it.