当前位置:网站首页>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])
边栏推荐
- “梦想杯”2017 年江苏省信息与未来小学生夏令营 IT 小能手 PK 之程序设计试题
- Application of OpenGL gllightfv function and related knowledge of light source
- Schnuka: machine vision positioning technology machine vision positioning principle
- 关于easyflash v3.3使用过程的记录
- Socket communication principle and Practice
- CAS mechanism
- 软考信息处理技术员有哪些备考资料与方法?
- [detailed explanation of Huawei machine test] tall and short people queue up
- [installation system] U disk installation system tutorial, using UltraISO to make U disk startup disk
- Common shortcut keys in IDA
猜你喜欢

【OneNote】无法连接到网络,无法同步问题

Trajectory planning for multi-robot systems: Methods and applications 综述阅读笔记

Mendeley -- a free document management tool that automatically inserts references into papers

Cluster task scheduling system lsf/sge/slurm/pbs based on HPC scenario

小程序跳转H5,配置业务域名经验教程

Find the greatest common divisor and the least common multiple (C language)
![1324: [example 6.6] integer interval](/img/5d/29db4d51ec7a2685f8aeffe5be68da.png)
1324: [example 6.6] integer interval

Leetcode-304: two dimensional area and retrieval - matrix immutable
![[système recommandé 01] rechub](/img/92/c14c867247d3a042c69b5ed0091fbe.png)
[système recommandé 01] rechub

I plan to take part in security work. How about information security engineers and how to prepare for the soft exam?
随机推荐
【STM32】实战3.1—用STM32与TB6600驱动器驱动42步进电机(一)
How embedded engineers improve work efficiency
CSAPP bomb lab parsing
SQL Server knowledge gathering 9: modifying data
Schnuka: machine vision positioning technology machine vision positioning principle
2022.7.3DAY595
Jump to the mobile terminal page or PC terminal page according to the device information
MONAI版本更新到 0.9 啦,看看有什么新功能
When do you usually get grades in the soft exam? Online pedaling?
小程序跳转H5,配置业务域名经验教程
OpenGL glLightfv 函数的应用以及光源的相关知识
P2788 math 1 - addition and subtraction
Find the greatest common divisor and the least common multiple (C language)
leetcode-304:二维区域和检索 - 矩阵不可变
Is the soft test intermediate useful??
软考中级,软件设计师考试那些内容,考试大纲什么的?
[daiy5] jz77 print binary tree in zigzag order
想考中级软考,一般需要多少复习时间?
Multithreaded asynchronous orchestration
深入理解Apache Hudi异步索引机制