滚屏效果(边缘不出)

var pt:Point = sceneView.worldView.globalToLocal(new Point(e.stageX-80,e.stageY-80)); //转换当前点的坐标到worldView上

 

 

private function conversionGotoPt(goalpt:Point):Point//目标点转化
  {
   var centerpt:Point = new Point(wSize / 2 - groundLayerView.x ,hSize / 2 - groundLayerView.y);
   var gotopt:Point = new Point(groundLayerView.x - (goalpt.x - centerpt.x),groundLayerView.y - (goalpt.y - centerpt.y));
   var topPt:Point = new Point(wSize/2,hSize/2);
   var topDownPt:Point = new Point(wSize/2,this.groundLayerView.height-(hSize/2));
   var leftPt:Point = new Point(this.groundLayerView.width-(wSize/2),hSize/2);
   var leftDownPt:Point = new Point(this.groundLayerView.width-(wSize/2),this.groundLayerView.height-(hSize/2));
   
   if(goalpt.x>leftPt.x && goalpt.y < leftPt.y)
   {
    gotopt.x = wSize-groundLayerView.width;
    gotopt.y = 0;
   }
   else if( goalpt.x>leftDownPt.x && goalpt.y > leftDownPt.y)
    {
     gotopt.x = wSize-groundLayerView.width;
    gotopt.y = hSize-groundLayerView.height;

   }
   else if(goalpt.x<topDownPt.x && goalpt.y > topDownPt.y)
   {
    gotopt.x = 0;
    gotopt.y = hSize-groundLayerView.height;
   }
   else if(goalpt.x<topPt.x && goalpt.y < topPt.y )
   {
    gotopt.x = 0;
    gotopt.y = 0;
   }
   else if(goalpt.x < (wSize/2))
   {
    gotopt.x = 0;
   }
   else if(goalpt.x > this.worldView.width-(wSize/2))
   {
    gotopt.x = wSize-groundLayerView.width;
   }
   else if(goalpt.y < (hSize/2))
   {
    gotopt.y = 0;
   }
   else if( goalpt.y > this.worldView.height-(hSize/2))
   {
    gotopt.y = hSize-groundLayerView.height;
   }
  
   return gotopt;
  }

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值