Jump to content

StaticCube

Members
  • Posts

    2
  • Joined

  • Last visited

Everything posted by StaticCube

  1. Actually fixed it myself . There was a lot wrong with this code (well 2 crucial things) . For people that have the same problem: - I was creating my own world (mWorld) but was using the one passed in as a parameter. - I forgot to recreate the camera which made the screen flicker Also crucial to note is that when creating your own world be sure to delete it (and delete the containing class) in the deconstructor.
  2. Hello Everyone, So I have started working on my game in leadwerks (C++). It has been really fun so far but for some strange reason I just can't get it to work the way I want. For now the project only consists of a few files and I was working on getting my SceneManager to work. The scenemanager should create the world / load worlds etc but when I run my code it keeps flickering the screen and doesn't load up the map correct. I have tried both world->clear and world->release but it keeps flickering the loading screen and doesn't return. So I hope someone could help me out and show me what I am doing wrong here (it works in my head ). #include "SceneManager.h" using namespace Leadwerks; SceneManager::SceneManager() { this->mLoadingTexture = NULL; this->mCustomLoadingTexture = NULL; } SceneManager::~SceneManager() { } bool SceneManager::Init() { // Create / Load a default placeholder for the loading screen this->mLoadingTexture = Texture::Load("Materials/UI/Loading_Default.tex"); if (this->mLoadingTexture == NULL) return LogUtil::returnWithMessage(LogType::LOG_ERROR, "Failed to load texture: 'Materials/UI/Loading_Default.tex'"); //this->mLoadingTexture->AddRef(); // Create / Load World this->mWorld = World::Create(); } bool SceneManager::LoadScene(std::string map, World* world, Context* context) { // Unload custom loading screen if loaded //this->UnloadCustomLoadingTexture(); // Now reload the load texture // First render the Loading Screen if (FileSystem::GetFileType("Materials/UI/Loading_" + map + ".tex") != NULL){ LogUtil::writeMessage(LogType::LOG_INFO, "Custom loadingscreen found: Materials/UI/Loading_" + map + ".tex"); // Try to load it this->mCustomLoadingTexture = Texture::Load("Materials/UI/Loading_" + map + ".tex"); //this->mCustomLoadingTexture->AddRef(); } else{ LogUtil::writeMessage(LogType::LOG_DEBUG, "Map doesn't have custom loadingscreen..."); } // Next render the loading screen (as the load map function blocks) if (mCustomLoadingTexture != NULL) context->DrawImage(mCustomLoadingTexture, 0, 0, context->GetWidth(), context->GetHeight()); else context->DrawImage(mLoadingTexture, 0, 0, context->GetWidth(), context->GetHeight()); context->Sync(false); // Clear the old world Time::Pause(); if ( world != NULL ) world->Release(); world = World::Create(); // Now load the actual map if (!Map::Load("Maps/" + map + ".map")){ // Failed to load map LogUtil::writeMessage(LogType::LOG_WARNING, "Failed to load map..."); } Time::Resume(); // The map is loaded now create a scene from it // TODO: CREATE A SCENE // Unload the custom loading texture now that we have build the scene //this->UnloadCustomLoadingTexture(); return true; } void SceneManager::UnloadCustomLoadingTexture() { if (this->mCustomLoadingTexture != NULL){ this->mCustomLoadingTexture->Release(); this->mCustomLoadingTexture = NULL; } } void SceneManager::Update() { if (mWorld != NULL) mWorld->Update(); } void SceneManager::Render() { if (mWorld != NULL) mWorld->Render(); } With kind regards, StaticCube
×
×
  • Create New...