Skip to content

Commit

Permalink
fix: visual storybook tests
Browse files Browse the repository at this point in the history
  • Loading branch information
eonarheim committed Dec 5, 2024
1 parent 4fdddb8 commit 8faedcb
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 20 deletions.
14 changes: 7 additions & 7 deletions src/stories/Actions.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const UsingActions: StoryObj = {

await game.start(loader);

game.setAntialiasing(false);
game.screen.antialiasing = false;

// Zoom in a bit
game.currentScene.camera.pos.setTo(game.halfDrawWidth, game.halfDrawHeight);
Expand Down Expand Up @@ -53,7 +53,7 @@ export const Fade: StoryObj = {

await game.start(loader);

game.setAntialiasing(false);
game.screen.antialiasing = false;

// Zoom in a bit
game.currentScene.camera.pos.setTo(game.halfDrawWidth, game.halfDrawHeight);
Expand Down Expand Up @@ -99,7 +99,7 @@ export const RotateTo: StoryObj = {

await game.start(loader);

game.setAntialiasing(false);
game.screen.antialiasing = false;

// Zoom in a bit
game.currentScene.camera.pos.setTo(game.halfDrawWidth, game.halfDrawHeight);
Expand Down Expand Up @@ -156,7 +156,7 @@ export const RotateBy: StoryObj = {

await game.start(loader);

game.setAntialiasing(false);
game.screen.antialiasing = false;

// Zoom in a bit
game.currentScene.camera.pos.setTo(game.halfDrawWidth, game.halfDrawHeight);
Expand Down Expand Up @@ -212,7 +212,7 @@ export const Move: StoryObj = {

await game.start(loader);

game.setAntialiasing(false);
game.screen.antialiasing = false;

// Zoom in a bit
game.currentScene.camera.pos.setTo(game.halfDrawWidth, game.halfDrawHeight);
Expand Down Expand Up @@ -264,7 +264,7 @@ export const Ease: StoryObj = {

await game.start(loader);

game.setAntialiasing(false);
game.screen.antialiasing = false;

// Zoom in a bit
game.currentScene.camera.pos.setTo(game.halfDrawWidth, game.halfDrawHeight);
Expand Down Expand Up @@ -316,7 +316,7 @@ export const Scale: StoryObj = {

await game.start(loader);

game.setAntialiasing(false);
game.screen.antialiasing = false;

// Zoom in a bit
game.currentScene.camera.pos.setTo(game.halfDrawWidth, game.halfDrawHeight);
Expand Down
12 changes: 6 additions & 6 deletions src/stories/Anchors.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class Cross extends Actor {
super({ x, y, width: 40, height: 40 });
this.graphics.onPreDraw = (ctx) => {
ctx.save();
// onPreDraw doesnt factor anchor anymore
// onPreDraw doesn't factor anchor anymore
ctx.translate(-20, -20);
ctx.debug.drawLine(vec(this.width / 2, 0), vec(this.width / 2, this.height), { color: Color.Black });
ctx.debug.drawLine(vec(0, this.height / 2), vec(this.width, this.height / 2), { color: Color.Black });
Expand Down Expand Up @@ -51,7 +51,7 @@ export const Centered: StoryObj = {
const ldr = new Loader([heartTx]);

game.backgroundColor = Color.White;
game.setAntialiasing(false);
game.screen.antialiasing = false;

// center anchored actors
const cc = new Cross(0, 0);
Expand Down Expand Up @@ -83,7 +83,7 @@ export const TopLeft: StoryObj = {
const ldr = new Loader([heartTx]);

game.backgroundColor = Color.White;
game.setAntialiasing(false);
game.screen.antialiasing = false;

// top left anchored actors
const tlc = new Cross(-100, -100);
Expand Down Expand Up @@ -137,7 +137,7 @@ export const TopRight: StoryObj = {
const ldr = new Loader([heartTx]);

game.backgroundColor = Color.White;
game.setAntialiasing(false);
game.screen.antialiasing = false;

// top right anchored actors
const trc = new Cross(100, -100);
Expand Down Expand Up @@ -168,7 +168,7 @@ export const BottomLeft: StoryObj = {
const ldr = new Loader([heartTx]);

game.backgroundColor = Color.White;
game.setAntialiasing(false);
game.screen.antialiasing = false;

// bottom left anchored actors
const blc = new Cross(-100, 100);
Expand Down Expand Up @@ -200,7 +200,7 @@ export const BottomRight: StoryObj = {
const ldr = new Loader([heartTx]);

game.backgroundColor = Color.White;
game.setAntialiasing(false);
game.screen.antialiasing = false;

const brc = new Cross(100, 100);
const bra1 = new Actor({ x: 100, y: 100, width: 15, height: 15, color: Color.Red, anchor: new Vector(1, 1) });
Expand Down
12 changes: 6 additions & 6 deletions src/stories/Audio.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export const PlayingASound: StoryObj = {

startOrPauseBtn.graphics.add('play', playSprite);
startOrPauseBtn.graphics.add('pause', pauseSprite);
startOrPauseBtn.graphics.show('play');
startOrPauseBtn.graphics.use('play');

startOrPauseBtn.on('pointerup', (evt) => {
if (!guitarLoopSound.isPlaying()) {
Expand All @@ -57,7 +57,7 @@ export const PlayingASound: StoryObj = {

evt.cancel();
});
stopBtn.graphics.show(stopSprite);
stopBtn.graphics.use(stopSprite);

const playheadStartPos = playTimeline.collider.bounds.left;
const playheadEndPos = playTimeline.collider.bounds.right;
Expand All @@ -73,14 +73,14 @@ export const PlayingASound: StoryObj = {
elapsedTime = 0;
playHead.actions.easeTo(playheadEndPos, playHead.pos.y, guitarLoopSound.duration * 1000, EasingFunctions.Linear);
}
startOrPauseBtn.graphics.show('pause');
startOrPauseBtn.graphics.use('pause');
action('playbackstart')(e);
});

guitarLoopSound.on('pause', (e) => {
elapsedTime = Date.now() - startTime + elapsedTime;
playHead.actions.clearActions();
startOrPauseBtn.graphics.show('play');
startOrPauseBtn.graphics.use('play');
action('pause')(e, elapsedTime);
});

Expand All @@ -89,14 +89,14 @@ export const PlayingASound: StoryObj = {
if (guitarLoopSound.duration > 0) {
playHead.actions.easeTo(playheadEndPos, playHead.pos.y, guitarLoopSound.duration * 1000 - elapsedTime, EasingFunctions.Linear);
}
startOrPauseBtn.graphics.show('pause');
startOrPauseBtn.graphics.use('pause');
action('resume')(e);
});

guitarLoopSound.on('playbackend', (e) => {
playHead.actions.clearActions();
playHead.pos.setTo(playheadStartPos, playHead.pos.y);
startOrPauseBtn.graphics.show('play');
startOrPauseBtn.graphics.use('play');
action('playbackend')(e);
});

Expand Down
2 changes: 1 addition & 1 deletion src/stories/Engine.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export const PlayButton: StoryObj = {
const heartTx = new ImageSource(heartTexture);
const loader = new Loader([heartTx]);
await game.start(loader);
game.setAntialiasing(false);
game.screen.antialiasing = false;
game.currentScene.camera.pos.setTo(game.halfDrawWidth, game.halfDrawHeight);
game.currentScene.camera.zoom = 4;
const heart = new Actor({
Expand Down

0 comments on commit 8faedcb

Please sign in to comment.