当前位置:网站首页>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])
边栏推荐
- 單調性約束與反單調性約束的區別 monotonicity and anti-monotonicity constraint
- 2022.7.4DAY596
- 在线硬核工具
- Mendeley -- a free document management tool that automatically inserts references into papers
- Records on the use of easyflash v3.3
- ArrayList thread insecurity and Solutions
- Leetcode-560: subarray with sum K
- 深入理解Apache Hudi异步索引机制
- 施努卡:机器视觉定位技术 机器视觉定位原理
- [牛客网刷题 Day6] JZ27 二叉树的镜像
猜你喜欢
随机推荐
[actual combat] transformer architecture of the major medical segmentation challenges on the list --nnformer
China Southern Airlines pa3.1
2022.7.6DAY598
ADB utility commands (network package, log, tuning related)
单调性约束与反单调性约束的区别 monotonicity and anti-monotonicity constraint
Elegant controller layer code
1323: [example 6.5] activity selection
Deep understanding of Apache Hudi asynchronous indexing mechanism
2022年7月10日“五心公益”活动通知+报名入口(二维码)
打算参加安全方面工作,信息安全工程师怎么样,软考考试需要怎么准备?
The mobile terminal automatically adjusts the page content and font size by setting rem
CSAPP bomb lab parsing
Using U2 net deep network to realize -- certificate photo generation program
[machine learning 03] Lagrange multiplier method
TypeScript 接口继承
Installation and configuration of slurm resource management and job scheduling system
About hzero resource error (groovy.lang.missingpropertyexception: no such property: weight for class)
宁愿把简单的问题说一百遍,也不把复杂的问题做一遍
Deep understanding of Apache Hudi asynchronous indexing mechanism
使用Tansformer分割三维腹部多器官--UNETR实战









