This repository has been archived by the owner on Sep 16, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 74
Relative depths for child Visuals #284
Comments
Just my two cents, but I also think something like this would be useful. |
Good idea! However, it might be confusing to have both class SomeEntity extends luxe.Sprite {
var icon :luxe.Sprite;
var text :luxe.Text;
public function new(options :SpriteOptions) {
super(options);
icon = new Sprite({
// ...
parent: this,
batcher: options.batcher,
scene: options.scene,
depth: options.depth + 0.01
});
text = new luxe.Text({
// ...
parent: this,
batcher: options.batcher,
scene: options.scene,
depth: options.depth + 0.02
});
}
} |
I suggest to make function in Luxe class: new Sprite({
name: "sprite1",
depth: 1, //depth 3
});
new Sprite({
name: "sprite2",
depth: 1.1, //depth 3.1
});
Luxe.something.relative_depth("sprite", 2); So, every sprite with name "sprite" will have depth 2 + original depth |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Current depth values are absolute. If you have a composite Sprite made up of many child Sprites and you change the depth of the parent, the depth of the children won't change together with it, which is inconvenient.
Visual
could have arelative_depth
field. If relative_depth is non-null and a parent is set, the child'sdepth
will be set to parent.depth + relative_depth. The child's depth should also change when the parent's depth changes.This behaviour can be mimicked by overriding update() to update the child's depth every frame, but it seems more efficient and organized to have in-built support for it.
(If this is ok, I can make a pull request.)
The text was updated successfully, but these errors were encountered: