当前位置:网站首页>LayaBox---TypeScript---Problems encountered at first contact
LayaBox---TypeScript---Problems encountered at first contact
2022-08-04 21:08:00 【Gragra】
目录
1.Drag and drop the image to the Hierarchy panel,F6执行,Not displayed in canvas
2.Public variables are defined in the script,Not displayed in the panel
3:选中物体,调整collider的x为负数时,运行时,物体消失.
问题5:Get the script mounted on the object through the object
问题7.Note that variables with the same name cannot be used even in different scripts
1.Drag and drop the image to the Hierarchy panel,F6执行,Not displayed in canvas
Tried a few times to find out The difference between the picture that is not displayed and the picture that is displayed is. Pictures that don't show are not set to‘不打包’.Try changing the image to unpacked,结果显示正常.
2.Public variables are defined in the script,Not displayed in the panel
/** @prop {name:intType, tips:"整数类型示例", type:Int, default:1000}*/
public intType: number = 1000;
/** @prop {name:numType, tips:"数字类型示例", type:Number, default:1000}*/
public numType: number = 1000;
/** @prop {name:strType, tips:"字符串类型示例", type:String, default:"hello laya"}*/
public strType: string = "hello laya";
/** @prop {name:boolType, tips:"布尔类型示例", type:Bool, default:true}*/
public boolType: boolean = true;
/** @prop {name:shoe,tips:"物体",type:Node,default:null}*/
public shoe = null;
// 更多参数说明请访问: https://ldc2.layabox.com/doc/?nav=zh-as-2-4-0Repeated research many times,最终发现问题出在layaAir IDE There is no automatic refresh mechanism,Objects not mounted by this script need to be manually selected,然后再回来,to refresh the newly defined variable properties.
very tightQ,Almost had to rewrite the blog as: LayaBoxFrom install to uninstall
3:选中物体,调整collider的x为负数时,运行时,物体消失.
It needs to be selected under the object in the hierarchy panelcollider组件,instead of selecting the object Then go to the properties panel to adjustcollider的位置.
4:Get object coordinates
NodeObjects of type have no coordinate properties,需要手动转为Laya.Sprite 或 3d的 Laya.Sprite3D
private own:Laya.Sprite = null;
this.own = this.owner as Laya.Sprite;
console.log(this.own.y);问题5:Get the script mounted on the object through the object
Scripts are mounted on topScene物体上,can't get the object.There is no way to get the script on the object

解决办法:Don't hook scripts to scene objects,Other sub-objects can be selected,Then you can get it.
/** @prop {name:score,tips:"物体",type:Node,default:null} */
score = null;
private scoreScript = null;
onAwake()
{
this.scoreScript = this.score.getComponent(ScorePanel);
}问题6:Variables exposed in the properties panel After panel assignment,In-code calls appear as null 或 undefined
Research for a long time did not find the reason and solution,Finally, replace it with code acquisition
private txt_timer:Laya.Text =null;
private txt_myScore:Laya.Text =null;
private txt_aiScore:Laya.Text =null;
onAwake()
{
this.txt_myScore = this.owner.getChildByName("txt_myScore") as Laya.Text;
this.txt_aiScore = this.owner.getChildByName("txt_aiScore") as Laya.Text;
this.txt_timer = this.owner.getChildByName("txt_timer") as Laya.Text;
}问题7.Note that variables with the same name cannot be used even in different scripts
问题8:如上,There is no problem getting the child objects under the script mounted object,You can't get other objects.
this.time_down = Laya.stage.getChildByName("txt_timeDown");调试结果 stage 下的child数量为0. 暂未解决
边栏推荐
猜你喜欢

STM32MP157A驱动开发 | 01- 板载LED作为系统心跳指示灯

Zynq Fpga图像处理之AXI接口应用——axi_lite接口使用
![[Data Mining] Written Exam Questions for Sohu Data Mining Engineers](/img/d9/450eeecd5c7835d40ac38da41fc08e.png)
[Data Mining] Written Exam Questions for Sohu Data Mining Engineers

SPSS-System Clustering Hand Calculation Practice

ADB 安装 + 打驱动全教程

使用堡塔应用管理器配置laravel队列方法

PowerCLi 导入License到vCenter 7
![[Teach you to use the serial port idle interrupt of the STM32HAL library]](/img/9e/88a11727e1452315edc2c8ac74690e.png)
[Teach you to use the serial port idle interrupt of the STM32HAL library]

遇到MapStruct后,再也不手写PO,DTO,VO对象之间的转换了

ts集成和使用
随机推荐
【手把手教你使用STM32HAL库的串口空闲中断】
[21 days learning challenge - kernel notes] (2), based in the device tree
[2022 Hangzhou Electric Power Multi-School 5 1012 Questions Buy Figurines] Application of STL
LINQ to SQL (Group By/Having/Count/Sum/Min/Max/Avg操作符)
PRIMAL: Pathfinding via Reinforcement and Imitation Multi-Agent Learning 代码解析
dotnet compress Stream or file using lz4net
[Academic related] Tsinghua professor persuaded to quit his Ph.D.:I have seen too many doctoral students have mental breakdowns, mental imbalances, physical collapses, and nothing!...
[TypeScript] In-depth study of TypeScript enumeration
Web3时代的战争
JWT主动校验Token是否过期
STM32MP157A驱动开发 | 01- 板载LED作为系统心跳指示灯
idea2021版本添加上一步和下一步操作到工具栏
Web3安全风险令人生畏,应该如何应对?
matlab drawing
Configure laravel queue method using fort app manager
How to make good use of builder mode
bracket matching
【1403. 非递增顺序的最小子序列】
3、IO流之字节流和字符流
基于单向链表结构的软件虚拟定时器的设计与构建