@author ixenos 2020-05-13 10:15:16

 

 

1.由于Laya在动态改变锚点时本身的坐标不会改变,不像在IDE编辑时的表现,因此我们手动改变他的坐标来实现动态锚点

2.动态锚点主要应用在显示对象实现不同锚点表现的动效衔接时

 1 public static function dynamicChangePivot(sp:Sprite,anchorV:Array):void{
 2     if(!sp || !anchorV || anchorV.length!=2)return;
 3     var prePX:Number = sp.pivotX;
 4     var prePY:Number = sp.pivotY;
 5     var aimPX:Number = anchorV[0]*sp.width;
 6     var aimPY:Number = anchorV[1]*sp.height;
 7     sp.x += (aimPX-prePX);
 8     sp.y += (aimPY-prePY);
 9     sp.pivot(aimPX,aimPY);
10 }

 

相关文章:

  • 2021-12-19
  • 2022-12-23
  • 2021-11-11
  • 2021-07-27
  • 2022-12-23
  • 2020-06-03
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-04-14
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-12
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案