当前位置:网站首页>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])
边栏推荐
- Schnuka: machine vision positioning technology machine vision positioning principle
- What are the contents of the intermediate soft test, the software designer test, and the test outline?
- Kotlin realizes wechat interface switching (fragment exercise)
- leetcode-304:二维区域和检索 - 矩阵不可变
- I plan to take part in security work. How about information security engineers and how to prepare for the soft exam?
- What are the test preparation materials and methods for soft exam information processing technicians?
- Simple and easy to modify spring frame components
- 软考中级电子商务师含金量高嘛?
- Multithreaded asynchronous orchestration
- About hzero resource error (groovy.lang.missingpropertyexception: no such property: weight for class)
猜你喜欢
Find the greatest common divisor and the least common multiple (C language)
The difference between monotonicity constraint and anti monotonicity constraint
P1031 [noip2002 improvement group] average Solitaire
When do you usually get grades in the soft exam? Online pedaling?
【推薦系統 01】Rechub
Socket communication principle and Practice
【机器学习 03】拉格朗日乘子法
优雅的 Controller 层代码
简单易修改的弹框组件
【OneNote】无法连接到网络,无法同步问题
随机推荐
Applet jump to H5, configure business domain name experience tutorial
关于easyflash v3.3使用过程的记录
Leetcode-304: two dimensional area and retrieval - matrix immutable
2022.7.3DAY595
Schnuka: machine vision positioning technology machine vision positioning principle
ThreadLocal is not enough
【作业】2022.7.6 写一个自己的cal函数
String formatting
Deeply analyze the main contents of erc-4907 agreement and think about the significance of this agreement to NFT market liquidity!
[daiy5] jz77 print binary tree in zigzag order
TypeScript 接口继承
Installation and configuration of slurm resource management and job scheduling system
1321: [example 6.3] deletion problem (noip1994)
小程序跳转H5,配置业务域名经验教程
【推薦系統 01】Rechub
Unable to open kernel device '\.\vmcidev\vmx': operation completed successfully. Reboot after installing vmware workstation? Module "devicepoweron" failed to start. Failed to start the virtual machine
Summary of router development knowledge
How to successfully pass the senior system architecture designer in the second half of the year?
[actual combat] transformer architecture of the major medical segmentation challenges on the list --nnformer
ADB utility commands (network package, log, tuning related)