File tree Expand file tree Collapse file tree 2 files changed +8
-3
lines changed
engine/modules/entities/src/main
java/com/codingame/gameengine/module/entities
resources/view/entity-module Expand file tree Collapse file tree 2 files changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ public abstract class Entity<T extends Entity<?>> {
1717
1818 private int x , y , zIndex ;
1919 private double scaleX = 1 , scaleY = 1 ;
20- private boolean visible = true ;
20+ private boolean visible = false ;
2121 private double rotation , alpha = 1 ;
2222 ContainerBasedEntity parent ;
2323 Mask mask ;
@@ -29,7 +29,12 @@ static enum Type {
2929 Entity () {
3030 id = ++GraphicEntityModule .ENTITY_COUNT ;
3131 state = new EntityState ();
32-
32+
33+ // World commits made before the creation of an entity should not affect that entity.
34+ // This is why we set `visible` to false by default and immediately setVisible(true),
35+ // this way the first commit of this entity will turn it into something visible.
36+ // All other properties have no impact while the entity is invisible so it is effectively non-existant until it's first commit.
37+ setVisible (true );
3338 }
3439
3540 @ SuppressWarnings ("unchecked" )
Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ export class Entity {
1313 scaleY : 1 ,
1414 zIndex : 0 ,
1515 alpha : 1 ,
16- visible : true ,
16+ visible : false ,
1717 rotation : 0 ,
1818 mask : - 1
1919 }
You can’t perform that action at this time.
0 commit comments