From 7cdeaedecbc7e87c105d06f864427b8ebcf2ead4 Mon Sep 17 00:00:00 2001 From: Erik Onarheim Date: Wed, 25 Jun 2025 07:56:32 -0500 Subject: [PATCH] docs: [#3450] remove errant references to `.show()` closes: #3450 --- sandbox/src/game.ts | 10 ----- .../04-graphics/04.2-graphics-component.mdx | 4 +- .../05-user-interface/02-screen-elements.mdx | 6 +-- site/docs/100-migrations.mdx | 2 +- site/docs/12-other/12-ui.mdx | 4 +- src/spec/vitest/ActorSpec.ts | 37 ------------------- 6 files changed, 8 insertions(+), 55 deletions(-) diff --git a/sandbox/src/game.ts b/sandbox/src/game.ts index bc755856..1cd9cb9a 100644 --- a/sandbox/src/game.ts +++ b/sandbox/src/game.ts @@ -793,16 +793,6 @@ var group = new ex.GraphicsGroup({ }); healthbar.graphics.use(group); -// var backgroundLayer = player.graphics.layers.create({ -// name: 'background', -// order: -1 -// }); - -// backgroundLayer.show(healthbar2, { offset: ex.vec(0, -70) }); - -// // playerText.showDebug = true; -// backgroundLayer.show(playerText, { offset: ex.vec(0, -70) }); - // Retrieve animations for player from sprite sheet var left = ex.Animation.fromSpriteSheet(spriteSheetRun, ex.range(1, 10), 50); // var left = new ex.Animation(game, left_sprites, 50); diff --git a/site/docs/04-graphics/04.2-graphics-component.mdx b/site/docs/04-graphics/04.2-graphics-component.mdx index 8901db7f..6164d573 100644 --- a/site/docs/04-graphics/04.2-graphics-component.mdx +++ b/site/docs/04-graphics/04.2-graphics-component.mdx @@ -37,9 +37,9 @@ The graphics component allows developers to save named graphics to avoid passing ```typescript actor.graphics.add('jump', jumpAnimation) -actor.graphics.show('jump') // display the graphic +actor.graphics.use('jump') // display the graphic // equivalent to -actor.graphics.show(jumpAnimation) // display the graphic +actor.graphics.use(jumpAnimation) // display the graphic actor.graphics.hide() // hide the graphic ``` diff --git a/site/docs/05-user-interface/02-screen-elements.mdx b/site/docs/05-user-interface/02-screen-elements.mdx index cc3bc654..4b7d82a6 100644 --- a/site/docs/05-user-interface/02-screen-elements.mdx +++ b/site/docs/05-user-interface/02-screen-elements.mdx @@ -38,15 +38,15 @@ class StartButton extends ex.ScreenElement { }) this.on('pointerenter', () => { - this.graphics.show('hover') + this.graphics.use('hover') }) this.on('pointerleave', () => { - this.graphics.show('idle') + this.graphics.use('idle') }) } } game.add(new StartButton()) game.start() -``` \ No newline at end of file +``` diff --git a/site/docs/100-migrations.mdx b/site/docs/100-migrations.mdx index 25169101..f1ef0932 100644 --- a/site/docs/100-migrations.mdx +++ b/site/docs/100-migrations.mdx @@ -69,7 +69,7 @@ section: Migration Guides } } ``` -- Graphics components no longer support layering built in, they now ONLY hold 1 graphic at a time. WIth this `actor.graphics.show()` is now deprecated. This change simplifies usage of graphics for folks building games and removes complexity caused by supporting layering and multiple graphics in Excalibur. +- Graphics components no longer support layering built in, they now ONLY hold 1 graphic at a time. With this `actor.graphics.show()` is now deprecated `graphics.use()` replaces the functionality. This change simplifies usage of graphics for folks building games and removes complexity caused by supporting layering and multiple graphics in Excalibur. - To use layering use 1. A [[GraphicsGroup]], you can specify a list of graphics in painter order (first is draw first, then so on) ```typescript diff --git a/site/docs/12-other/12-ui.mdx b/site/docs/12-other/12-ui.mdx index 1295f1f4..580f664a 100644 --- a/site/docs/12-other/12-ui.mdx +++ b/site/docs/12-other/12-ui.mdx @@ -47,11 +47,11 @@ class StartButton extends ex.ScreenElement { }) this.on('pointerenter', () => { - this.graphics.show('hover') + this.graphics.use('hover') }) this.on('pointerleave', () => { - this.graphics.show('idle') + this.graphics.use('idle') }) } } diff --git a/src/spec/vitest/ActorSpec.ts b/src/spec/vitest/ActorSpec.ts index 43a8b161..68cac7ad 100644 --- a/src/spec/vitest/ActorSpec.ts +++ b/src/spec/vitest/ActorSpec.ts @@ -844,43 +844,6 @@ describe('A game actor', () => { await expect(engine.canvas).toEqualImage('/src/spec/assets/images/SpriteSpec/opacity.png'); }); - // it('will tick animations when drawing switched', async () => { - // const texture = new ex.ImageSource('/src/spec/assets/images/SpriteSpec/icon.png'); - // await texture.load(); - // const sprite = new ex.Sprite({ - // image: texture, - // width: 62, - // height: 64, - // rotation: 0, - // scale: new ex.Vector(1, 1), - // flipVertical: false, - // flipHorizontal: false - // }); - // const animation = new ex.Animation({ - // frames: [{graphic: sprite }, {graphic: sprite }], - // frameDuration: 200, - // strategy: ex.AnimationStrategy.Loop, - // rotation: Math.PI, - // scale: new ex.Vector(2, 2), - // flipVertical: true, - // flipHorizontal: true, - // width: 100, - // height: 200 - // }); - - // spyOn(animation, 'tick') - - // const actor = new ex.Actor({ - // pos: new ex.Vector(engine.halfCanvasWidth, engine.halfCanvasHeight), - // width: 10, - // height: 10 - // }); - - // actor.graphics.add('default', animation); - // actor.graphics.show('default'); - // expect(animation.tick).toHaveBeenCalledWith(0); - // }); - it('will tick animations on update', async () => { scene.clear(); const texture = new ex.ImageSource('/src/spec/assets/images/SpriteSpec/icon.png'); -- 2.51.2