Add sprite sorting and transparency

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

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

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

Loading…
Cancel
Save