Skip to content

Commit

Permalink
Recentering the red dot for the animal skaters, see #347
Browse files Browse the repository at this point in the history
  • Loading branch information
AgustinVallejo committed Nov 30, 2022
1 parent ca35b9b commit 9189d3e
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions js/common/view/SkaterNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,26 @@ class SkaterNode extends Node {
} );
this.children = [ leftSkaterImageNode, rightSkaterImageNode ];

// Show a red dot in the bottom center as the important particle model coordinate
const circle = new Circle( 8, { fill: 'red' } );
this.addChild( circle );

// @public - One of SkaterImages.SkaterImageSet, with images for left and right motion. Controls the skater
// character.
this.skaterImageSetProperty = new Property( SkaterImages.SKATER_CHARACTER_SETS[ 0 ].imageSet1 );

let imageWidth;
let imageHeight;

this.skaterImageSetProperty.link( skaterImage => {
leftSkaterImageNode.image = skaterImage.leftImage;
rightSkaterImageNode.image = skaterImage.rightImage;

imageWidth = leftSkaterImageNode.width;
imageHeight = leftSkaterImageNode.height;

circle.x = imageWidth / 2;
circle.y = imageHeight;
} );

// @private {Skater}
Expand All @@ -74,8 +87,6 @@ class SkaterNode extends Node {
rightSkaterImageNode.visible = direction === Skater.Direction.RIGHT;
} );

const imageWidth = this.width;
const imageHeight = this.height;

// @private - Map from mass(kg) to the amount to scale the image
const centerMassValue = skater.massRange.getCenter();
Expand Down Expand Up @@ -120,11 +131,8 @@ class SkaterNode extends Node {
translation.freeToPool();

this.setMatrix( matrix );
} );

// Show a red dot in the bottom center as the important particle model coordinate
const circle = new Circle( 8, { fill: 'red', x: imageWidth / 2, y: imageHeight } );
this.addChild( circle );
} );

let targetTrack = null;

Expand Down

0 comments on commit 9189d3e

Please sign in to comment.