Skip to content

Commit

Permalink
Fixed text positioning
Browse files Browse the repository at this point in the history
  • Loading branch information
alice-i-cecile committed May 6, 2021
2 parents f707dc0 + 3e3f5bd commit 68a598d
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions examples/ecs/per_entity_events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ struct Selectable;
#[derive(Bundle)]
struct InteractableBundle {
#[bundle]
text_bundle: TextBundle,
text_bundle: Text2dBundle,
selectable: Selectable,
rainbow: Rainbow,
cycle_color_events: Events<CycleColorAction>,
Expand All @@ -62,7 +62,7 @@ impl InteractableBundle {
// FIXME: fix position
fn new(x: f32, y: f32, font_handle: &Handle<Font>) -> Self {
InteractableBundle {
text_bundle: TextBundle {
text_bundle: Text2dBundle {
text: Text::with_section(
"0",
TextStyle {
Expand Down Expand Up @@ -134,19 +134,19 @@ struct AddNumberAction {

fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
// Don't forget to include a camera!
commands.spawn_bundle(UiCameraBundle::default());
commands.spawn_bundle(OrthographicCameraBundle::new_2d());

let font_handle = asset_server.load("fonts/FiraSans-Bold.ttf");
// Spawns the first entity, and grabs the Entity id that is being allocated
let first_entity = commands
.spawn_bundle(InteractableBundle::new(-200.0, 400.0, &font_handle))
.spawn_bundle(InteractableBundle::new(-200.0, 0.0, &font_handle))
.id();
commands.insert_resource(Selected {
entity: first_entity,
});

commands.spawn_bundle(InteractableBundle::new(0.0, 400.0, &font_handle));
commands.spawn_bundle(InteractableBundle::new(200.0, 400.0, &font_handle));
commands.spawn_bundle(InteractableBundle::new(0.0, 0.0, &font_handle));
commands.spawn_bundle(InteractableBundle::new(200.0, 0.0, &font_handle));
}

enum CycleBehavior {
Expand Down

0 comments on commit 68a598d

Please sign in to comment.