ScrollRect设置会引起其他的UI资源无法正在显示

我用的版本是1.7.9
package
{

import laya.display.Node;
import laya.display.Sprite;
import laya.maths.Rectangle;
import laya.ui.Image;
import laya.utils.Handler;

import ui.TestViewUI;

public class TestView extends TestViewUI
{
private var PATH_LEN:Number = 120.0;
private var speed:Number = 15;

private var _path:Sprite = new Sprite();
private var arr:Array = [];
public function TestView()
{
super();
_path.pivot(0,0);
_path.pos(a.x,a.y);
this.addChild(_path);
_path.rotation = Math.atan2(b.y - a.y, b.x - a.x) / Math.PI * 180;
var len:int = Math.floor(GetPathLen()/PATH_LEN)+2;
var p:Image;
for(var i:int = 0;i<len;i++){
p = new Image("test/footprint.png");
p.pos(i*PATH_LEN,0);
arr.push(p);
_path.addChild(p);
}
//注释下面这行就正常了
_path.scrollRect = new Rectangle(0,0,(len-1)*PATH_LEN,58);
btn_start.clickHandler = new Handler(this,StartMove,[len]);
}

private function StartMove(len:int):void
{
trace("[TestView.StartMove]")
// TODO Auto Generated method stub
Laya.timer.loop(100,this,UpdatePath,[len]);
}

private function UpdatePath(len:int):void
{
// TODO Auto Generated method stub
var show:int = len -1;
for(var i=0;i<len;i++){
if(arr[i]){
arr[i].x+= speed;
if(arr[i].x>= show* PATH_LEN){
arr[i].x-=show* PATH_LEN;
}
}
}
}

private function GetPathLen():Number
{
// TODO Auto Generated method stub
var disX:Number = a.x-b.x;
var disY:Number = a.y-b.y;
var p:Number = Math.sqrt(disX*disX+disY*disY);
return p;
}



}
}
1.png 2.png
已邀请:

EveryQ

赞同来自:

Laya.init(1136, 640,WebGL);
初始化用的是WebGL

ymsdandan

赞同来自:

估计是你Rectangle 对象是 laya.maths.Rectangle的引用 没有赋值过来

要回复问题请先

商务合作
商务合作