@@ -489,33 +489,34 @@ export class Sprite extends SpriteBase {
489
489
let dy = - Math . sin ( rad ) ;
490
490
switch ( nearestEdge ) {
491
491
case Sprite . Edge . LEFT :
492
- dx = Math . max ( 0.2 , Math . abs ( dx ) ) ;
493
- break ;
492
+ dx = Math . max ( 0.2 , Math . abs ( dx ) ) ;
493
+ break ;
494
494
case Sprite . Edge . RIGHT :
495
- dx = - Math . max ( 0.2 , Math . abs ( dx ) ) ;
496
- break ;
495
+ dx = - Math . max ( 0.2 , Math . abs ( dx ) ) ;
496
+ break ;
497
497
case Sprite . Edge . TOP :
498
- dy = Math . max ( 0.2 , Math . abs ( dy ) ) ;
499
- break ;
498
+ dy = Math . max ( 0.2 , Math . abs ( dy ) ) ;
499
+ break ;
500
500
case Sprite . Edge . BOTTOM :
501
- dy = - Math . max ( 0.2 , Math . abs ( dy ) ) ;
502
- break ;
501
+ dy = - Math . max ( 0.2 , Math . abs ( dy ) ) ;
502
+ break ;
503
503
}
504
504
this . direction = this . degToScratch ( this . radToDeg ( Math . atan2 ( dy , dx ) ) ) ;
505
- const { x, y} = this . keepInFence ( this . x , this . y ) ;
505
+ const { x, y } = this . keepInFence ( this . x , this . y ) ;
506
506
this . goto ( x , y ) ;
507
507
}
508
508
509
509
keepInFence ( newX , newY ) {
510
510
// https://github.com/LLK/scratch-vm/blob/develop/src/sprites/rendered-target.js#L949
511
511
const fence = this . stage . fence ;
512
512
const bounds = this . _project . renderer . getBoundingBox ( this ) ;
513
- bounds . left += ( newX - this . x ) ;
514
- bounds . right += ( newX - this . x ) ;
515
- bounds . top += ( newY - this . y ) ;
516
- bounds . bottom += ( newY - this . y ) ;
513
+ bounds . left += newX - this . x ;
514
+ bounds . right += newX - this . x ;
515
+ bounds . top += newY - this . y ;
516
+ bounds . bottom += newY - this . y ;
517
517
518
- let dx = 0 , dy = 0 ;
518
+ let dx = 0 ,
519
+ dy = 0 ;
519
520
if ( bounds . left < fence . left ) {
520
521
dx += fence . left - bounds . left ;
521
522
}
@@ -528,10 +529,10 @@ export class Sprite extends SpriteBase {
528
529
if ( bounds . bottom < fence . bottom ) {
529
530
dy += fence . bottom - bounds . bottom ;
530
531
}
531
- return ( {
532
+ return {
532
533
x : newX + dx ,
533
534
y : newY + dy
534
- } ) ;
535
+ } ;
535
536
}
536
537
537
538
get penDown ( ) {
@@ -625,35 +626,35 @@ export class Sprite extends SpriteBase {
625
626
}
626
627
627
628
nearestEdge ( ) {
628
- const bounds = this . _project . renderer . getBoundingBox ( this ) ;
629
- const { width : stageWidth , height : stageHeight } = this . stage ;
630
- const distLeft = Math . max ( 0 , ( stageWidth / 2 ) + bounds . left ) ;
631
- const distTop = Math . max ( 0 , ( stageHeight / 2 ) - bounds . top ) ;
632
- const distRight = Math . max ( 0 , ( stageWidth / 2 ) - bounds . right ) ;
633
- const distBottom = Math . max ( 0 , ( stageHeight / 2 ) + bounds . bottom ) ;
634
- // Find the nearest edge.
635
- let nearestEdge = '' ;
636
- let minDist = Infinity ;
637
- if ( distLeft < minDist ) {
638
- minDist = distLeft ;
639
- nearestEdge = Sprite . Edge . LEFT ;
640
- }
641
- if ( distTop < minDist ) {
642
- minDist = distTop ;
643
- nearestEdge = Sprite . Edge . TOP ;
644
- }
645
- if ( distRight < minDist ) {
646
- minDist = distRight ;
647
- nearestEdge = Sprite . Edge . RIGHT ;
648
- }
649
- if ( distBottom < minDist ) {
650
- minDist = distBottom ;
651
- nearestEdge = Sprite . Edge . BOTTOM ;
652
- }
653
- if ( minDist > 0 ) {
654
- nearestEdge = null ;
655
- }
656
- return nearestEdge ;
629
+ const bounds = this . _project . renderer . getBoundingBox ( this ) ;
630
+ const { width : stageWidth , height : stageHeight } = this . stage ;
631
+ const distLeft = Math . max ( 0 , stageWidth / 2 + bounds . left ) ;
632
+ const distTop = Math . max ( 0 , stageHeight / 2 - bounds . top ) ;
633
+ const distRight = Math . max ( 0 , stageWidth / 2 - bounds . right ) ;
634
+ const distBottom = Math . max ( 0 , stageHeight / 2 + bounds . bottom ) ;
635
+ // Find the nearest edge.
636
+ let nearestEdge = "" ;
637
+ let minDist = Infinity ;
638
+ if ( distLeft < minDist ) {
639
+ minDist = distLeft ;
640
+ nearestEdge = Sprite . Edge . LEFT ;
641
+ }
642
+ if ( distTop < minDist ) {
643
+ minDist = distTop ;
644
+ nearestEdge = Sprite . Edge . TOP ;
645
+ }
646
+ if ( distRight < minDist ) {
647
+ minDist = distRight ;
648
+ nearestEdge = Sprite . Edge . RIGHT ;
649
+ }
650
+ if ( distBottom < minDist ) {
651
+ minDist = distBottom ;
652
+ nearestEdge = Sprite . Edge . BOTTOM ;
653
+ }
654
+ if ( minDist > 0 ) {
655
+ nearestEdge = null ;
656
+ }
657
+ return nearestEdge ;
657
658
}
658
659
659
660
say ( text ) {
0 commit comments