- Edited
hello,
I have this object to change levels, unfortunately the camera limitW / limitH isn't fast enought in some situations, i get small flickering.
**next_level.gd
func _process(delta):
if ( timer > 0 ):
timer -= 1*delta;
return;
if ( levelGO == true ):
levelGO = false;
if ( Player != null ):
get_tree().change_scene_to_file(nextLevel);
Player.position = Vector2(plrnextX, plrnextY);
func _on_area_2d_body_entered(body):
if ( timer > 0 ):
return;
if body.is_in_group("player"):
levelGO = true;
***mini_map.gd (GUI)
func _physics_process(_delta):
if ( lvlName != get_tree().get_current_scene().name ):
lvlName = get_tree().get_current_scene().name;
lvl_ini_POS = get_tree().get_current_scene().map_POS;
if ( Player != null ):
lvlCamTile = get_tree().get_current_scene().get_child(0);
Player.cam2D.limit_right = lvlCamTile.get_region_rect().size.x;
Player.cam2D.limit_bottom = lvlCamTile.get_region_rect().size.y;
Iam using a node sprite with region enable to use has the level W / H
The problem here is...
( ex: the player is already on the next level and for 1 milisecond / cicle, the camera limits are still on the previous level )
if i want to stop that small flickering that happens on some ocasions i have to input the camera limits manually on the next level object, iam already writing the player X and Y. And camera limits adds extra confusion, of opening and closing tabs, some levels have 3 doors...
Is there a way to access the "get_tree().change_scene_to_file(nextLevel);" for a node in this case "lvlCamTile = get_tree().get_current_scene().get_child(0);"
nextLevel = res://levels/lvl_e7.tscn
Iam trying to avoid this in all next_level objects, has i have to input the values manually
func _process(delta):
if ( timer > 0 ):
timer -= 1*delta;
return;
if ( levelGO == true ):
levelGO = false;
if ( Player != null ):
get_tree().change_scene_to_file(nextLevel);
Player.position = Vector2(plrnextX, plrnextY);
Player.cam2D.zoom = Vector2( camZoom, camZoom );
Player.cam2D.limit_right = camLimitX; ### trying to avoid this
Player.cam2D.limit_bottom = camLimitY; ### trying to avoid this