[]关于graphics._saveToCmd的问题
this.sp.graphics._saveToCmd(this.test1,arr);
执行上面代码的代码后,会一直执行this.test1函数,如何让它只执行一次呢?
执行上面代码的代码后,会一直执行this.test1函数,如何让它只执行一次呢?
没有找到相关结果
已邀请:
要回复问题请先登录
2 个回复
cuixueying
赞同来自:
bluesky
赞同来自:
// 程序入口
import Sprite = Laya.Sprite;
import Stage = Laya.Stage;
class GameMain{
private sp:Sprite;
constructor()
{
Laya.init(600,400);
this.sp = new Laya.Sprite();
Laya.stage.addChild(this.sp);
var arr:Array<any> = [this.sp,1,2,3];
this.sp.graphics._saveToCmd(this.test1,arr);
}
test1(x,y,args):void
{
console.log("args[0]"+args[0]+",args[1]"+args[1]+",args[2]"+args[2])
var sp:Laya.Sprite = args[0];
//sp.graphics.clear();
var ctx=Laya.Render._context.ctx;
ctx.fillStyle="#FF0000";
ctx.fillRect(0,0,300,150);
ctx.clearRect(20,20,100,50);
}
}
new GameMain();
Laya.Stat.show(0, 0);//TODO 显示帧率