-
Notifications
You must be signed in to change notification settings - Fork 69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Loading custom sprite assets #236
Comments
You can actually use a custom implementation of #[derive(Default, Bundle)]
pub struct PlayerBundle {
aseprite_bundle: AsepriteBundle
// other player components..
}
impl LdtkEntity for PlayerBundle {
fn bundle_entity(
entity_instance: &EntityInstance,
layer_instance: &LayerInstance,
tileset: Option<&Handle<Image>>,
tileset_definition: Option<&TilesetDefinition>,
asset_server: &AssetServer,
texture_atlases: &mut Assets<TextureAtlas>
) -> Self {
// build your PlayerBundle here
}
} You also have other options than the macros when spawning entities, and it's definitely not ideal when you need more access to the world than the macros/ #[derive(Default, Component)]
struct PlayerMarker;
// register this to the app via one of the LdtkEntityAppExt methods
#[derive(Default, Bundle, LdtkEntity)]
struct PlayerBundle {
marker: PlayerMarker,
}
fn add_aseprite_to_player(
mut commands: Commands,
asset_server: Res<AssetServer>,
player_query: Query<(Entity, &Transform), Added<PlayerMarker>>
) {
// add any component/bundle you want to the player, with access to the asset server
} Personally I prefer doing the latter since implementing |
Thanks, I'll go with the second method. There's this issue: #177, but will the workflow for this kind of stuff improve in the future? I feel that expecting the user to always use |
It will. However, it might not be in the form #177 is proposing. Right now I'm gradually working on improving the "blueprint pattern" (in particular, making it easier to access LDtk asset data from normal systems). I don't really expect users to always use a |
I'm trying to use bevy_aseprite to load my player sprite. It looks like that this crate heavily relies on macros in order to load entity assets, so I'm not sure how to integrate it.
The
bevy_aseprite
library requires the user to have the following bundle in the entity:Since you're not supposed to spawn the entities manually, how do I pass the asset into the bundle? Do I need to make a custom macro for this?
The text was updated successfully, but these errors were encountered: