Reset Without Reset?

23 views
Skip to first unread message

xhunterko

unread,
Nov 13, 2015, 4:00:08 PM11/13/15
to HaxeFlixel
When I go resetState or switchState, what ACTUALLY happens to the state? Because the lighting system I have plugged in works on state creation and state reset and switch. However, when I want to load new lighting areas to go with a new level, it retains the original lighting areas. For example:

createRooms();

//do stuff

createLights();

createLights:void

if stage is 1
    new light things

//THEN after so many enemies are killed, switch the level out with a new one and it's new lighting

if stage is 2
   new light things

Here's stage 2:

if (Stage == 2)
       
{    
           
//Add Light Segments        
           
//////////////////////////////////
           
            vis
= new Visibility();
            vis
.loadMap(1024);        
           
           
           
//125,137 ... 145 ... 155 ... 165
            vis
.addSegment(125, 137, 145, 138);
           
           
           
//Stationary Lights        
            lFixed1
= new RayLight(344, 230, vis);
            lFixed1
.color = 0x6A0404;        
            lightMan
.addLight(lFixed1);
           
LightHOLDINGB.add(lFixed1);    
           
            lPlayer
= new RayLight(180, 160, vis, PlayerKnight);        
            lPlayer
.alpha = 0.55;            
           
            lightMan
= new LightManager();// 0xff000055);        
            lightMan
.alpha = 0.75; //Replaced by Variable compared to level
            lightMan
.addLight(lPlayer);
           
           
           
LightHOLDINGB.add(lightMan);    
       
}


Stage 1 is the same except with more segments. So I thought, it works fine on start up, okay, just simulate a fresh start up should fix it, right? So I figured since destroy is called, let's just make a false destroy.

public function destroyRooms():Void
   
{
        lPlayer
= null;
       
//Everything else is null as well like in the actual destroy and the tilemap's exist is set to false    
   
}

However that doesn't unload the segments. I have tried a couple things with wacky results.

Setting lightholding.exists = false removes the lighting entirely of course but going lightholding.exists = true in the create lights does not make it reappear.

vis.segments.close; causes no change to occur. Same thing with remove. And depending on where I put those, where you think they should go, has caused the level itself for some unknown reason, to disappear entirely!

What should I do here? Has anyone worked with this lighting system: http://haxeflixel.com/forum/?place=msg%2Fhaxeflixel%2F8IX0tTHifsQ%2Fk8A3QD6wWiYJ

before and knows how it works and what I should do? I'm simply trying to remove segments and add new ones. Any ideas how to do this?


Jeru Sanders

unread,
Nov 13, 2015, 4:32:05 PM11/13/15
to HaxeFlixel
Switch/reset state basically recursively destroys all your FlxBasics. I'd have to see the full source to the lighting system. But I'd guess that you have to call something like "vis.destroy()"
Reply all
Reply to author
Forward
0 new messages