Add sprite sorting and transparency

master
Hilmar Wiegand 5 years ago
parent 988a8f9b57
commit 1e682ede22

@ -2,7 +2,10 @@ use amethyst::{
assets::Processor,
core::transform::TransformBundle,
prelude::*,
renderer::{types::DefaultBackend, RenderingSystem, SpriteSheet},
renderer::{
sprite_visibility::SpriteVisibilitySortingSystem, types::DefaultBackend, RenderingSystem,
SpriteSheet,
},
utils::application_root_dir,
window::WindowBundle,
};
@ -24,6 +27,11 @@ fn main() -> amethyst::Result<()> {
let game_data = GameDataBuilder::default()
.with_bundle(WindowBundle::from_config_path(display_config))?
.with_bundle(TransformBundle::new())?
.with(
SpriteVisibilitySortingSystem::new(),
"sprite_visibility_system",
&["transform_system"],
)
.with(
Processor::<SpriteSheet>::new(),
"sprite_sheet_processor",

@ -1,7 +1,7 @@
use amethyst::{
ecs::prelude::{ReadExpect, Resources, SystemData},
renderer::{
pass::DrawFlat2DDesc,
pass::DrawFlat2DTransparentDesc,
rendy::{
factory::Factory,
graph::{
@ -75,7 +75,8 @@ impl GraphCreator<DefaultBackend> for RenderGraph {
// Add additional draw groups here for things like UI
let pass = builder.add_node(
SubpassBuilder::new()
.with_group(DrawFlat2DDesc::new().builder()) // Draw sprites
// Draw sprites with transparency
.with_group(DrawFlat2DTransparentDesc::new().builder())
.with_color(color)
.with_depth_stencil(depth)
.into_pass(),

Loading…
Cancel
Save