Fix Scroll Area demo scene (#3261)

Fix the `scroll-area` example scene, so that a red circle inside the scroll area, and a gray rounded rectangle representing the background of the scroll area, are now both visible.

Previously, adding just a `Sprite` (instead of a corresponding `SpriteSystem`) to the scene resulted in the underlying `Symbol` not being added to a visible `Layer`. (Notably, `Sprite::display_object()` is not the same as `Sprite::symbol.display_object()`.)

https://www.pivotaltracker.com/story/show/180459079
This commit is contained in:
Mateusz Czapliński 2022-02-17 13:01:53 +01:00 committed by GitHub
parent dbcc2548df
commit 8f61ec174e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -73,7 +73,7 @@ fn init(app: &Application) {
let background_shape = Rect(background_size).corners_radius(5.5.px()).fill(background_color);
let background_system = ShapeSystem::new(scene, background_shape);
let background: Sprite = background_system.new_instance();
scene.add_child(&background);
scene.add_child(&background_system);
background.size.set(Vector2::new(200.0, 200.0));
background.set_position_x(100.0);
background.set_position_y(-100.0);
@ -93,7 +93,7 @@ fn init(app: &Application) {
let sprite_system = ShapeSystem::new(scene, &Circle(50.px()));
let sprite: Sprite = sprite_system.new_instance();
scroll_area.content.add_child(&sprite);
scroll_area.content.add_child(&sprite_system);
sprite.size.set(Vector2::new(100.0, 100.0));
sprite.set_position_x(100.0);
sprite.set_position_y(-100.0);