当前位置:网站首页>Laya common script commands
Laya common script commands
2022-07-07 10:49:00 【HCC2017】
let isGameover = false; Declare global variables
----------------------------------------------------------------------------------------------------------------------------------------------------------------
/** @prop {name:force, tips:" Example of integer type ", type:Number, default:null}*/
this.force = null; Declare global variables
----------------------------------------------------------------------------------------------------------------------------------------------------------------
onAwake() {
Laya.stage.on(Laya.Event.MOUSE_DOWN, this, this.mouseDown); Listen for mouse down events And call methods
}
mouseDown() {}
------------------------------------------------------------------------------------------------------------------------------------------------------------------
onAwake() {
this.owner.getComponent(Laya.RigidBody).type = "static"; Get the components on the object mounted by this script and modify the type
this.txt_Rank = this.rankPanel.getChildByName("txt_Rank"); Get the object whose name matches in this object subclass
this.gameoverPanel.getChildByName("btn_Again").on(Laya.Event.CLICK, this, this.btnAgainClick) Find object button Add listening Events
this.txt_Score.text = "Score:" to text assignment
this.txt_Score.visible = false; Hidden objects
}
---------------------------------------------------------------------------------------------------------------------------------------------------------------------
this.owner.rotation = 0; Control the rotation of this object
this.owner.autoAnimation = "Idle"; The animation state of this object is played
this.owner.loop = false; Animation state does not cycle
Laya.SoundManager.playSound("audio/fly.mp3", 1); obtain vsCode In the project bin Music resources under the directory and play
---------------------------------------------------------------------------------------------------------------------------------------------------------------------
Laya.stage.on("Start", this, function() { }) When a broadcast is received Logical processing of script method under this object
Laya.stage.event("Start") Send a broadcast
----------------------------------------------------------------------------------------------------------------------------------------------------------------------
var bottomColumn = this.coumnPre.create(); Clone preform coumnPre Prefabricate for incoming variables
columnParent.addChild(bottomColumn); Set as sub object
bottomColumn.pos(1920, 1080) Generation location
bottomColumn.getComponent(Column).canAddScore = true; Get the script on the object and assign values to variables
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
columnArr = []; Array declaration
columnArr.push(TopColumn); Add array members
columnArr.forEach(element => {
element.removeSelf();
}); Traverse and delete the contents of the array
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
var TopColumn = Laya.Pool.getItemByCreateFun("Colum", this.creatFun, this); Object pool
creatFun() { var temp = this.coumnPre.create(); return temp; }
this.owner.removeSelf(); Delete yourself from the parent container
Laya.Pool.recover("Column", this.owner); Recycle yourself into the pool
------------------------------------------------------------------------------------------------------------------------------------------------------- ------------------------------
bubbleSort(arr) { Bubble sort
var len = arr.length;
for (var i = 0; i < len; i++) {
for (var j = 0; j < len - i - 1; j++) {
if (arr[j] < arr[j + 1]) {
var temp = arr[j + 1];
arr[j + 1] = arr[j];
arr[j] = temp;
}
}
}
return arr;
}
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
var one = Number(Laya.LocalStorage.getItem("One")); Get the value of the specified key name
var two = Number(Laya.LocalStorage.getItem("Two"));
var three = Number(Laya.LocalStorage.getItem("Three"));
var scoreArr = [];
scoreArr.push(one, two, three, score); Adding values to an array
score = 0;
scoreArr = this.bubbleSort(scoreArr); Sort
Laya.LocalStorage.setItem("One", scoreArr[0]) Store the specified key name and key value , String type .
Laya.LocalStorage.setItem("Two", scoreArr[1])
Laya.LocalStorage.setItem("Three", scoreArr[2])
边栏推荐
- CAS机制
- 软考一般什么时候出成绩呢?在线蹬?
- MySQL insert data create trigger fill UUID field value
- Deep understanding of Apache Hudi asynchronous indexing mechanism
- 宁愿把简单的问题说一百遍,也不把复杂的问题做一遍
- 如何顺利通过下半年的高级系统架构设计师?
- The mobile terminal automatically adjusts the page content and font size by setting rem
- Prototype and prototype chain
- 成为优秀的TS体操高手 之 TS 类型体操前置知识储备
- [pytorch 07] hands on deep learning chapter_ Preliminaries/ndarray exercises hands-on version
猜你喜欢
CAS mechanism
Find the root of equation ax^2+bx+c=0 (C language)
CSAPP Bomb Lab 解析
高级软考(网络规划设计师)该如何备考?
【实战】霸榜各大医学分割挑战赛的Transformer架构--nnFormer
【亲测可行】error while loading shared libraries的解决方案
July 10, 2022 "five heart public welfare" activity notice + registration entry (two-dimensional code)
Using tansformer to segment three-dimensional abdominal multiple organs -- actual battle of unetr
[STM32] solution to the problem that SWD cannot recognize devices after STM32 burning program
CAS机制
随机推荐
使用U2-Net深层网络实现——证件照生成程序
香橙派OrangePi 4 LTS开发板通过Mini PCIE连接SATA硬盘的操作方法
I plan to take part in security work. How about information security engineers and how to prepare for the soft exam?
How to prepare for the advanced soft test (network planning designer)?
TypeScript 接口继承
无法打开内核设备“\\.\VMCIDev\VMX”: 操作成功完成。是否在安装 VMware Workstation 后重新引导? 模块“DevicePowerOn”启动失败。 未能启动虚拟机。
[OneNote] can't connect to the network and can't sync the problem
软考中级有用吗??
【推荐系统 01】Rechub
[système recommandé 01] rechub
【作业】2022.7.6 写一个自己的cal函数
多线程-异步编排
PHP \ newline cannot be output
openinstall与虎扑达成合作,挖掘体育文化产业数据价值
Summary of router development knowledge
[牛客网刷题 Day6] JZ27 二叉树的镜像
Hdu-2196 tree DP learning notes
String formatting
小程序跳转H5,配置业务域名经验教程
单调性约束与反单调性约束的区别 monotonicity and anti-monotonicity constraint