Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

移除文本时,laya的sprite的graphics将不会显示 #81

Open
icegarden opened this issue Mar 12, 2023 · 0 comments
Open

移除文本时,laya的sprite的graphics将不会显示 #81

icegarden opened this issue Mar 12, 2023 · 0 comments

Comments

@icegarden
Copy link

Laya版本:2.13.1
代码如下:
Laya.stage.addChild(fairygui.GRoot.inst.displayObject);
let tf = new fairygui.GBasicTextField();
tf.x = 400;
tf.y = 200;
tf.fontSize = 30;
tf.color = "#ffff00";
tf.text = "2222222222";
fairygui.GRoot.inst.addChild(tf);
let sp = new Laya.Sprite();
sp.graphics.drawRect(0, 0, 200, 300, "#ff0000");
Laya.stage.addChild(sp);
Laya.timer.once(1000, this, () => {
// tf.removeFromParent();
tf.visible = false;
});
首先保证是一个空项目
这个项目中只有一个fairygui的textfield实例,还有一个源生laya的Sprite,这个sprite是个红色矩形
两个都添加到舞台上,延时一秒移除textfield,或者将其visible设为false
大概再一秒过后这个红色矩形就会消失,从内存里看,sp还在,只是无法绘制出来
目录如果想让红色矩形存在,就需要new一个textfield放在那,并且要赋值文本(一个空字符串)
QQ录屏20230312215915 00_00_02--00_00_05

QQ.20230312215915.mp4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant