mirror of
https://github.com/Leo501/CocosCreatorTutorial.git
synced 2026-05-18 04:35:41 +08:00
添加高亮动画
This commit is contained in:
22
UIAnimDemo/assets/Script/HelloWorld.js
Normal file
22
UIAnimDemo/assets/Script/HelloWorld.js
Normal file
@@ -0,0 +1,22 @@
|
||||
cc.Class({
|
||||
extends: cc.Component,
|
||||
|
||||
properties: {
|
||||
label: {
|
||||
default: null,
|
||||
type: cc.Label
|
||||
},
|
||||
// defaults, set visually when attaching this script to the Canvas
|
||||
text: 'Hello, World!'
|
||||
},
|
||||
|
||||
// use this for initialization
|
||||
onLoad: function () {
|
||||
this.label.string = this.text;
|
||||
},
|
||||
|
||||
// called every frame
|
||||
update: function (dt) {
|
||||
|
||||
},
|
||||
});
|
||||
9
UIAnimDemo/assets/Script/HelloWorld.js.meta
Normal file
9
UIAnimDemo/assets/Script/HelloWorld.js.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "1.0.5",
|
||||
"uuid": "280c3aec-6492-4a9d-9f51-a9b00b570b4a",
|
||||
"isPlugin": false,
|
||||
"loadPluginInWeb": true,
|
||||
"loadPluginInNative": true,
|
||||
"loadPluginInEditor": false,
|
||||
"subMetas": {}
|
||||
}
|
||||
30
UIAnimDemo/assets/Script/HighlightAnim.js
Normal file
30
UIAnimDemo/assets/Script/HighlightAnim.js
Normal file
@@ -0,0 +1,30 @@
|
||||
|
||||
cc.Class({
|
||||
extends: cc.Component,
|
||||
|
||||
properties: {
|
||||
isPlay: false
|
||||
},
|
||||
|
||||
// LIFE-CYCLE CALLBACKS:
|
||||
|
||||
// onLoad () {},
|
||||
|
||||
start() {
|
||||
if (this.isPlay) {
|
||||
this.play(1, 1.2, 0.2);
|
||||
}
|
||||
},
|
||||
|
||||
play(time = 1, scale = 1.3, delayTime = 0.2) {
|
||||
let sequn = cc.sequence(cc.spawn(cc.scaleTo(time, scale),
|
||||
cc.fadeOut(time).easing(cc.easeOut(2))), cc.callFunc(() => {
|
||||
this.node.scale = 1;
|
||||
this.node.opacity = 255;
|
||||
this.node.active = true;
|
||||
}, cc.delayTime(delayTime)));
|
||||
this.node.runAction(sequn.repeatForever());
|
||||
}
|
||||
|
||||
// update (dt) {},
|
||||
});
|
||||
9
UIAnimDemo/assets/Script/HighlightAnim.js.meta
Normal file
9
UIAnimDemo/assets/Script/HighlightAnim.js.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "1.0.5",
|
||||
"uuid": "1abcd28a-7b39-49a6-a09c-7dabd946efdc",
|
||||
"isPlugin": false,
|
||||
"loadPluginInWeb": true,
|
||||
"loadPluginInNative": true,
|
||||
"loadPluginInEditor": false,
|
||||
"subMetas": {}
|
||||
}
|
||||
Reference in New Issue
Block a user