开始按钮动效

This commit is contained in:
TJH 2025-12-18 16:37:45 +08:00
parent 0efd166fae
commit 9ca0d6cc1d
3 changed files with 1583 additions and 3372 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
import { _decorator, CCInteger, Component, tween, Vec3, Node, Animation, Tween } from 'cc'; import { _decorator, CCInteger, Component, tween, Vec3, Node, Animation, Tween, Skeleton, sp } from 'cc';
const { ccclass, property } = _decorator; const { ccclass, property } = _decorator;
@ccclass('SpinAni') @ccclass('SpinAni')
@ -21,36 +21,39 @@ export class SpinAni extends Component {
onLoad() { onLoad() {
this.playIdleSpin(); this.playIdleSpin();
this.buttonAnimation.play('BtnSpin_idle_animation'); // this.buttonAnimation.play('BtnSpin_idle_animation');
} }
private playIdleSpin() { private playIdleSpin() {
Tween.stopAllByTarget(this.rotateNode); // Tween.stopAllByTarget(this.rotateNode);
const duration = 360 / this.idleRotationSpeed * this.time; // const duration = 360 / this.idleRotationSpeed * this.time;
tween(this.rotateNode) // tween(this.rotateNode)
.by(duration, { eulerAngles: new Vec3(0, 0, -360) }) // .by(duration, { eulerAngles: new Vec3(0, 0, -360) })
.repeatForever() // .repeatForever()
.start(); // .start();
this.rotateNode.getComponent(sp.Skeleton).setAnimation(0, '1', true)
} }
public startSpin() { public startSpin() {
Tween.stopAllByTarget(this.rotateNode); // Tween.stopAllByTarget(this.rotateNode);
const duration = 360 / this.runRotationSpeed * this.time; // const duration = 360 / this.runRotationSpeed * this.time;
tween(this.rotateNode) // tween(this.rotateNode)
.by(duration, { eulerAngles: new Vec3(0, 0, -360) }) // .by(duration, { eulerAngles: new Vec3(0, 0, -360) })
.repeatForever() // .repeatForever()
.start(); // .start();
this.buttonAnimation.play('BtnSpin_spin_animation'); // this.buttonAnimation.play('BtnSpin_spin_animation');
// this.buttonAnimation.once(Animation.EventType.FINISHED, () => {
// this.buttonAnimation.play('BtnSpin_idle_animation');
// });
this.rotateNode.getComponent(sp.Skeleton).setAnimation(0, '2', true)
this.buttonAnimation.once(Animation.EventType.FINISHED, () => {
this.buttonAnimation.play('BtnSpin_idle_animation');
});
} }
public stopSpin() { public stopSpin() {
this.playIdleSpin(); this.playIdleSpin();
this.buttonAnimation.off(Animation.EventType.FINISHED); // this.buttonAnimation.off(Animation.EventType.FINISHED);
this.buttonAnimation.play('BtnSpin_idle_animation'); // this.buttonAnimation.play('BtnSpin_idle_animation');
} }
} }

View File

@ -23,7 +23,7 @@
"_active": true, "_active": true,
"_components": [], "_components": [],
"_prefab": { "_prefab": {
"__id__": 105 "__id__": 89
}, },
"_lpos": { "_lpos": {
"__type__": "cc.Vec3", "__type__": "cc.Vec3",
@ -54,7 +54,7 @@
}, },
"autoReleaseAssets": false, "autoReleaseAssets": false,
"_globals": { "_globals": {
"__id__": 106 "__id__": 90
}, },
"_id": "6c29a3fe-b10e-44a5-98e3-55595b231767" "_id": "6c29a3fe-b10e-44a5-98e3-55595b231767"
}, },
@ -89,16 +89,16 @@
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 101 "__id__": 85
}, },
{ {
"__id__": 102 "__id__": 86
}, },
{ {
"__id__": 103 "__id__": 87
}, },
{ {
"__id__": 104 "__id__": 88
} }
], ],
"_prefab": null, "_prefab": null,
@ -3042,247 +3042,112 @@
}, },
{ {
"__type__": "cc.Node", "__type__": "cc.Node",
"_name": "testspin",
"_objFlags": 0, "_objFlags": 0,
"__editorExtras__": {},
"_parent": { "_parent": {
"__id__": 2 "__id__": 2
}, },
"_prefab": { "_children": [],
"_active": false,
"_components": [
{
"__id__": 83 "__id__": 83
}, },
"__editorExtras__": {}
},
{ {
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 82
},
"asset": {
"__uuid__": "2c62af7c-9b93-48ff-bd76-a2dfd799659e",
"__expectedType__": "cc.Prefab"
},
"fileId": "fchELCmEtHhb3lT1fagDGR",
"instance": {
"__id__": 84 "__id__": 84
},
"targetOverrides": null,
"nestedPrefabInstanceRoots": null
},
{
"__type__": "cc.PrefabInstance",
"fileId": "5fPthmo8NIQar0JHf7WtK2",
"prefabRootNode": null,
"mountedChildren": [],
"mountedComponents": [],
"propertyOverrides": [
{
"__id__": 85
},
{
"__id__": 87
},
{
"__id__": 88
},
{
"__id__": 89
},
{
"__id__": 90
},
{
"__id__": 92
},
{
"__id__": 93
},
{
"__id__": 95
},
{
"__id__": 96
},
{
"__id__": 97
},
{
"__id__": 98
},
{
"__id__": 100
} }
], ],
"removedComponents": [] "_prefab": null,
}, "_lpos": {
{
"__type__": "CCPropertyOverrideInfo",
"targetInfo": {
"__id__": 86
},
"propertyPath": [
"_name"
],
"value": "Icon2"
},
{
"__type__": "cc.TargetInfo",
"localID": [
"fchELCmEtHhb3lT1fagDGR"
]
},
{
"__type__": "CCPropertyOverrideInfo",
"targetInfo": {
"__id__": 86
},
"propertyPath": [
"_lpos"
],
"value": {
"__type__": "cc.Vec3", "__type__": "cc.Vec3",
"x": 705.446, "x": 748.77,
"y": 0, "y": 0,
"z": 0 "z": 0
}
}, },
{ "_lrot": {
"__type__": "CCPropertyOverrideInfo",
"targetInfo": {
"__id__": 86
},
"propertyPath": [
"_lrot"
],
"value": {
"__type__": "cc.Quat", "__type__": "cc.Quat",
"x": 0, "x": 0,
"y": 0, "y": 0,
"z": 0, "z": 0,
"w": 1 "w": 1
}
}, },
{ "_lscale": {
"__type__": "CCPropertyOverrideInfo", "__type__": "cc.Vec3",
"targetInfo": { "x": 1,
"__id__": 86 "y": 1,
"z": 1
}, },
"propertyPath": [ "_mobility": 0,
"_euler" "_layer": 33554432,
], "_euler": {
"value": {
"__type__": "cc.Vec3", "__type__": "cc.Vec3",
"x": 0, "x": 0,
"y": 0, "y": 0,
"z": 0 "z": 0
} },
"_id": "0e78JTflVDFZ4NIUdhurzm"
}, },
{ {
"__type__": "CCPropertyOverrideInfo", "__type__": "cc.UITransform",
"targetInfo": { "_name": "",
"__id__": 91 "_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 82
}, },
"propertyPath": [ "_enabled": true,
"defaultAnimation" "__prefab": null,
], "_contentSize": {
"value": "idle"
},
{
"__type__": "cc.TargetInfo",
"localID": [
"b78oDPY8JE7osWArFEHKzB"
]
},
{
"__type__": "CCPropertyOverrideInfo",
"targetInfo": {
"__id__": 86
},
"propertyPath": [
"_active"
],
"value": false
},
{
"__type__": "CCPropertyOverrideInfo",
"targetInfo": {
"__id__": 94
},
"propertyPath": [
"_contentSize"
],
"value": {
"__type__": "cc.Size", "__type__": "cc.Size",
"width": 172, "width": 381.8599853515625,
"height": 144.74000549316406 "height": 381.8599853515625
}
}, },
{ "_anchorPoint": {
"__type__": "cc.TargetInfo",
"localID": [
"59LoecK5tD7pJBy73qYDy6"
]
},
{
"__type__": "CCPropertyOverrideInfo",
"targetInfo": {
"__id__": 94
},
"propertyPath": [
"_anchorPoint"
],
"value": {
"__type__": "cc.Vec2", "__type__": "cc.Vec2",
"x": 0.5, "x": 0.4830304405381119,
"y": 0.4265579614157381 "y": 0.4830304405381119
} },
"_id": "7f5YblwE5H84qJc33lO18N"
}, },
{ {
"__type__": "CCPropertyOverrideInfo", "__type__": "sp.Skeleton",
"targetInfo": { "_name": "",
"__id__": 91 "_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 82
}, },
"propertyPath": [ "_enabled": true,
"_skeletonData" "__prefab": null,
], "_customMaterial": null,
"value": { "_srcBlendFactor": 2,
"__uuid__": "cd685b14-f3cc-44a8-b277-ebcee9084c66", "_dstBlendFactor": 4,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_skeletonData": {
"__uuid__": "582eae3a-683a-4e08-a104-52d0744fba47",
"__expectedType__": "sp.SkeletonData" "__expectedType__": "sp.SkeletonData"
}
}, },
{ "defaultSkin": "default",
"__type__": "CCPropertyOverrideInfo", "defaultAnimation": "2",
"targetInfo": { "_premultipliedAlpha": false,
"__id__": 91 "_timeScale": 1,
}, "_preCacheMode": 0,
"propertyPath": [ "_cacheMode": 0,
"defaultSkin" "_sockets": [],
], "_useTint": false,
"value": "default" "_debugMesh": false,
}, "_debugBones": false,
{ "_debugSlots": false,
"__type__": "CCPropertyOverrideInfo", "_enableBatch": false,
"targetInfo": { "loop": true,
"__id__": 99 "_id": "01GyqhsktDVYsIEIn+wgLG"
},
"propertyPath": [
"_active"
],
"value": false
},
{
"__type__": "cc.TargetInfo",
"localID": [
"826d+8u4VAE5zPnBQxlZk6"
]
},
{
"__type__": "CCPropertyOverrideInfo",
"targetInfo": {
"__id__": 91
},
"propertyPath": [
"_premultipliedAlpha"
],
"value": false
}, },
{ {
"__type__": "cc.UITransform", "__type__": "cc.UITransform",
@ -3392,38 +3257,33 @@
"asset": null, "asset": null,
"fileId": "6c29a3fe-b10e-44a5-98e3-55595b231767", "fileId": "6c29a3fe-b10e-44a5-98e3-55595b231767",
"instance": null, "instance": null,
"targetOverrides": [], "targetOverrides": []
"nestedPrefabInstanceRoots": [
{
"__id__": 82
}
]
}, },
{ {
"__type__": "cc.SceneGlobals", "__type__": "cc.SceneGlobals",
"ambient": { "ambient": {
"__id__": 107 "__id__": 91
}, },
"shadows": { "shadows": {
"__id__": 108 "__id__": 92
}, },
"_skybox": { "_skybox": {
"__id__": 109 "__id__": 93
}, },
"fog": { "fog": {
"__id__": 110 "__id__": 94
}, },
"octree": { "octree": {
"__id__": 111 "__id__": 95
}, },
"skin": { "skin": {
"__id__": 112 "__id__": 96
}, },
"lightProbeInfo": { "lightProbeInfo": {
"__id__": 113 "__id__": 97
}, },
"postSettings": { "postSettings": {
"__id__": 114 "__id__": 98
}, },
"bakedWithStationaryMainLight": false, "bakedWithStationaryMainLight": false,
"bakedWithHighpLightmap": false "bakedWithHighpLightmap": false