开始按钮动效

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;
@ccclass('SpinAni')
@ -21,36 +21,39 @@ export class SpinAni extends Component {
onLoad() {
this.playIdleSpin();
this.buttonAnimation.play('BtnSpin_idle_animation');
// this.buttonAnimation.play('BtnSpin_idle_animation');
}
private playIdleSpin() {
Tween.stopAllByTarget(this.rotateNode);
const duration = 360 / this.idleRotationSpeed * this.time;
tween(this.rotateNode)
.by(duration, { eulerAngles: new Vec3(0, 0, -360) })
.repeatForever()
.start();
// Tween.stopAllByTarget(this.rotateNode);
// const duration = 360 / this.idleRotationSpeed * this.time;
// tween(this.rotateNode)
// .by(duration, { eulerAngles: new Vec3(0, 0, -360) })
// .repeatForever()
// .start();
this.rotateNode.getComponent(sp.Skeleton).setAnimation(0, '1', true)
}
public startSpin() {
Tween.stopAllByTarget(this.rotateNode);
const duration = 360 / this.runRotationSpeed * this.time;
tween(this.rotateNode)
.by(duration, { eulerAngles: new Vec3(0, 0, -360) })
.repeatForever()
.start();
this.buttonAnimation.play('BtnSpin_spin_animation');
// Tween.stopAllByTarget(this.rotateNode);
// const duration = 360 / this.runRotationSpeed * this.time;
// tween(this.rotateNode)
// .by(duration, { eulerAngles: new Vec3(0, 0, -360) })
// .repeatForever()
// .start();
// 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() {
this.playIdleSpin();
this.buttonAnimation.off(Animation.EventType.FINISHED);
this.buttonAnimation.play('BtnSpin_idle_animation');
// this.buttonAnimation.off(Animation.EventType.FINISHED);
// this.buttonAnimation.play('BtnSpin_idle_animation');
}
}

View File

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