Hi.. I have a problem...
orxSTATUS orxFASTCALL StandAlone::Init()
{
...
orxEvent_AddHandler(orxEVENT_TYPE_INPUT, StandAlone::EventHandler);
orxEvent_AddHandler(orxEVENT_TYPE_SOUND, StandAlone::EventHandler);
...
}
Why when i load another config file, events doesn't work anymore?
PD: Sorry for my bad english
Comments
Don't worry about your English, it's perfectly understandable and mine is probably not better anyway.
As for your problem, could you give us more details? What do you do for loading another config file?
As long as your event handlers have been registered, they should stay registered unless you unregister them yourself or you exit from orx.
To explain this I will use the google translator because I do not know how to explain it in English :P
And Google says:
I divided the game "levels". When I change one level for another, the game will automatically load a configuration file related to it.
One level would be similar to a "room" of GameMaker.
Example:
Level 1
name = 'Presentation'
file = 'Presentation.ini'
Level 2
name = 'MainWindow'
file = 'MainWindow.ini'
I never delete a handler, but if I did not register handlers again doesn't work.
Can you show us the code you're using to actually do this?
Main.cpp
#include "Game/StandAlone.h"
using namespace VirtualFufy;
#ifdef __releaseWIN__
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
// Inits and executes orx
orx_WinExecute(StandAlone::Init, StandAlone::Run, StandAlone::Exit);
// Done!
return EXIT_SUCCESS;
}
#else
int main( int argc, char** argv )
{
orx_Execute( argc, argv, StandAlone::Init, StandAlone::Run, StandAlone::Exit );
return EXIT_SUCCESS;
}
#endif
StandAlone.cpp
...
orxSTATUS orxFASTCALL StandAlone::Init()
{
try
{
// Iniciar administrador
orxLOG("Iniciando administrador...");
admin = new Logic::Administrador();
admin->Iniciar();
orxLOG("OK");
// Iniciar el engine
orxLOG("Iniciando engine...");
motor = new VirtualFufy::VirtualFufyGame();
motor->Iniciar();
orxLOG("OK");
// Registramos manejadores de eventos
//orxEvent_AddHandler(orxEVENT_TYPE_INPUT, StandAlone::EventHandler);
//orxEvent_AddHandler(orxEVENT_TYPE_SOUND, StandAlone::EventHandler);
// Registrar función de update
orxCLOCK *pstClock;
pstClock = orxClock_FindFirst(orx2F(-1.0f), orxCLOCK_TYPE_CORE);
orxClock_Register(pstClock, Update, orxNULL, orxMODULE_ID_MAIN, orxCLOCK_PRIORITY_NORMAL);
// Success!
return orxSTATUS_SUCCESS;
}
catch(std::exception &ex)
{
orxLOG(ex.what());
return orxSTATUS_FAILURE;
}
catch(...)
{
return orxSTATUS_FAILURE;
}
}
...
GameEngine.cpp
...
void GameEngine::Update()
{
// Si se desea cambiar de nivel...
if(nivelNuevo != nivel)
{
if(nivel != NULL)
{
std::vector<GameObject*>* persistentes = nivel->Finalizar();
for(std::size_t i=0; i<persistentes->size(); ++i)
{
nivelNuevo->AgregarSobreviviente((*persistentes));
}
delete persistentes;
}
nivelNuevo->Cargar();
nivelNuevo->Iniciar();
nivel = nivelNuevo;
}
...
GameLevel.cpp
namespace Engine
{
GameLevel::GameLevel()
{
this->nombre = "none";
this->file = "none";
this->viewport = orxNULL;
}
GameLevel::GameLevel(const string nombre, const string file)
{
this->nombre = nombre;
this->file = file;
this->viewport = orxNULL;
}
GameLevel::~GameLevel()
{
Liberar();
}
void GameLevel::Cargar()
{
string mensaje;
mensaje = "Cargando nivel ";
mensaje += nombre.c_str();
mensaje += "...";
orxLOG(mensaje.c_str());
orxConfig_Load(file.c_str());
orxInput_Load(orxSTRING_EMPTY);
viewport = orxViewport_CreateFromConfig("Viewport");
// Re-agregar el event handler????
orxEvent_AddHandler(orxEVENT_TYPE_INPUT, VirtualFufy::StandAlone::EventHandler);
orxEvent_AddHandler(orxEVENT_TYPE_SOUND, VirtualFufy::StandAlone::EventHandler);
orxLOG("OK");
}
void GameLevel::Liberar()
{
for(GAMELEVEL_IT it = objetos.begin(); it != objetos.end(); it++)
{
GameObject* obj = it->second;
delete obj;
obj = NULL;
}
if(viewport != orxNULL)
{
orxViewport_Delete(viewport);
viewport = orxNULL;
}
}
...
Btw, which version of orx are you using, the latest package or the svn? I'd advise using the svn as the latest package is getting pretty old now.
If you still can't find the issue, don't hesitate to zip your project and send it to me so that I can have a look. I keep all sent projects private, of course.
I have one problem... i don't have orx source code. i'm using the lastest package...
"Btw, which version of orx are you using, the latest package or the svn? I'd advise using the svn as the latest package is getting pretty old now."
I'll do it... how could compile "orx" to generate the corresponding libraries for Windows and Linux? or in svn is already compiled?
"If you still can't find the issue, don't hesitate to zip your project and send it to me so that I can have a look. I keep all sent projects private, of course."
If i can't find the error, i haven't problem
I could not compile my game. Then, i changed libs "sqlite3.lib orxd.lib" to "sqlite3.lib imporxd.lib orxd.lib" and now compile.
My new problem: when i execute my application, this exit with an error.
Yes, you can compile orx from the SVN and it'll compile out of the box. But you already figured that out.
Now for the config options, they're explained in the README. The ones you want are the embedded dynamic release/profile/debug.
Embedded means that all the plugins are embedded at compile time, and not hotloaded at runtime (more efficient).
You'll then find the .lib in /code/lib/dynamic. Don't forget to replace the runtime libraries (.dll) and include files (/code/include) for your own project or they won't be compatible with the new version you just compiled.
Embedded debug:
Error 1 fatal error LNK1257: code generation failed orxLIB orxLIB
Embedded release:
IDEM
mmm... output:
Looking at the source code, I found that I do things wrong.
Example (see FreeConfig()):
I should use "orxObject_SetLifeTime(myObject, orxFLOAT_0);" instead of "orxObject_Delete(myObject);"?
Header: GameObject.h
Have you tried to clean/rebuild?
Also which version of visual studio are you using? 2008?
and yes, i'm using vs2008
Rebuild:
Aaah, ok! I still I can't make me friend of "orx philosophy" :P
I'm calling FreeConfig in
When you get the svn version compiled, in debug, you'll get an assert if you call the delete function from an event handler.
No worries, we're here for that and it's better to ask questions than staying stuck.
Ahh, now i understand
And that means we're not using the same version of vs2008. Apparently yours is older than mine. You'll have to recompile orx's external dependencies.
They're all in the /extern folder.
The one you need for windows are: glfw, Box2D, openal-soft, SOIL and libsndfile.
Thank you very much for your help! and see you on Thursday!
You should have less trouble on linux though, including 64b, as long as you have libsndfile/openal installed on your distribution (orx use the vanilla ones on linux, the modified ones are only for windows).
See you on Thursday!
What do you mean by latest versions? The latest source is always available from the SVN and it's changing too often for me to keep updated source packages.
As for binary packages, I don't make them more than once a year as it takes me 6-8 hours to generate them.
Though I'd like to help you to compile orx on your own, this way you'll be able to do it any time you need a newer version!
Can you give me more details on what went wrong when compiling?
I attached "buildlog.htm"
I attached "buildlog.htm" https://forum.orx-project.org/uploads/legacy/fbfiles/files/BuildLog.txt
The issue is that even if I send you a binary made with my vs2008, it will still not work for you as you'll get the same error message when linking your game.
Your only option is to compile orx's dependencies in the orx/extern folder.
There are vs2008 solutions for all of them, the ones you need to recompile are:
- Box2D_2.1.3
- glfw-2.7
- openal-soft
- SOIL
Let me know if that works for you!
Compiling:
1- OK
2- OK
3- Error, missing dsound.h
4- OK
Searching on google... Founded! Problem: missing DXSDK.
Downloading DXSDK...
(3 years later...)
Downloaded!
Installing...
Installed!
Compiling 3 again...
Not founded!
Referencing DXSDK include dir...
Compiling again... YES!!
I write this way because I find it difficult to explain the process of what I did.
Compiling ORX... YES, COMPILED!!
Now, what? jeje :P
edit:What is that plugin? SFML and others?
Don't pay attention to the SDL and SFML plugins, the most recent ones are GLFW.
Also if you compile orx with the "embedded" configurations, the plugins will be inside orx.lib, so you don't have to worry about them at all.
Well now you have your own version of orx, the headers are in orx/code/include and the compiled libraries are in orx/code/library/dynamic (both .lib and .dll). That's all you need for developing your game.