layer(name: string): LayerComp
Determines the layer for objects. Object will be drawn on top if the layer index is higher.
param
name- The layer name to set.
// Define layers layers(["background", "game", "foreground"], "game") const bean = add([ sprite("bean"), pos(100, 100), layer("background"), ]) // Mark is in a higher layer, so he will be drawn on top of bean const mark = add([ sprite("mark"), pos(100, 100), layer("game"), ]) bean.layer("foreground") // Bean is now in the foreground layer and will be drawn on top of mark
returns
The layer comp.
since
v3001.0